47
47
#include "vtim.h"
48
48
49
49
/*--------------------------------------------------------------------
50
- * TODO: describe.
50
+ * Facility to keep obcore references until the end of the task across restarts
51
51
*/
52
52
53
53
struct ocstash {
54
- unsigned l ;
55
- unsigned n ;
54
+ unsigned magic ;
55
+ #define OCSTASH_MAGIC 0x242031b5
56
+ uint16_t l ;
57
+ uint16_t n ;
56
58
struct objcore * ocs [] v_counted_by_ (l );
57
59
};
58
60
59
61
static void
60
62
ocstash_push (struct ocstash * stash , struct objcore * * ocp )
61
63
{
62
64
63
- AN (stash );
65
+ CHECK_OBJ_NOTNULL (stash , OCSTASH_MAGIC );
64
66
assert (stash -> n < stash -> l );
65
67
TAKE_OBJ_NOTNULL (stash -> ocs [stash -> n ], ocp , OBJCORE_MAGIC );
66
68
stash -> n ++ ;
@@ -69,10 +71,11 @@ ocstash_push(struct ocstash *stash, struct objcore **ocp)
69
71
static void
70
72
ocstash_clear (struct worker * wrk , struct ocstash * stash )
71
73
{
72
- unsigned u ;
74
+ uint16_t u ;
73
75
74
76
CHECK_OBJ_NOTNULL (wrk , WORKER_MAGIC );
75
- AN (stash );
77
+ CHECK_OBJ_NOTNULL (stash , OCSTASH_MAGIC );
78
+ assert (stash -> n <= stash -> l );
76
79
for (u = 0 ; u < stash -> n ; u ++ )
77
80
(void )HSH_DerefObjCore (wrk , & stash -> ocs [u ], HSH_RUSH_POLICY );
78
81
for (; u < stash -> l ; u ++ )
@@ -172,7 +175,7 @@ Req_New(struct sess *sp)
172
175
{
173
176
struct pool * pp ;
174
177
struct req * req ;
175
- uint16_t nhttp ;
178
+ uint16_t l , nhttp ;
176
179
unsigned sz , hl ;
177
180
char * p , * e ;
178
181
@@ -232,10 +235,12 @@ Req_New(struct sess *sp)
232
235
p = (void * )PRNDUP (p + sizeof (* req -> top ));
233
236
234
237
req -> max_restarts = cache_param -> max_restarts ;
235
- sz = SIZEOF_FLEX_OBJ (req -> stash , ocs , req -> max_restarts + 1 );
238
+ assert (req -> max_restarts + 1 <= UINT16_MAX );
239
+ l = req -> max_restarts + 1 ;
240
+ sz = SIZEOF_FLEX_OBJ (req -> stash , ocs , l );
236
241
req -> stash = (void * )p ;
237
- ZERO_OBJ ( req -> stash , sz ) ;
238
- req -> stash -> l = req -> max_restarts + 1 ;
242
+ req -> stash -> magic = OCSTASH_MAGIC ;
243
+ req -> stash -> l = l ;
239
244
p += sz ;
240
245
p = (void * )PRNDUP (p );
241
246
0 commit comments