Commit 46cc55c5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add an advisory hint to object iterators signalling that this is

the last segment.
parent 7fd371e0
...@@ -686,7 +686,10 @@ int ObjHasAttr(struct worker *, struct objcore *, enum obj_attr); ...@@ -686,7 +686,10 @@ int ObjHasAttr(struct worker *, struct objcore *, enum obj_attr);
const void *ObjGetAttr(struct worker *, struct objcore *, enum obj_attr, const void *ObjGetAttr(struct worker *, struct objcore *, enum obj_attr,
ssize_t *len); ssize_t *len);
typedef int objiterate_f(void *priv, int flush, const void *ptr, ssize_t len); typedef int objiterate_f(void *priv, unsigned flush,
const void *ptr, ssize_t len);
#define OBJ_ITER_FLUSH 0x01
#define OBJ_ITER_FINAL 0x02
int ObjIterate(struct worker *, struct objcore *, int ObjIterate(struct worker *, struct objcore *,
void *priv, objiterate_f *func, int final); void *priv, objiterate_f *func, int final);
......
...@@ -138,8 +138,9 @@ VDP_close(struct req *req) ...@@ -138,8 +138,9 @@ VDP_close(struct req *req)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static int v_matchproto_(objiterate_f) static int v_matchproto_(objiterate_f)
vdp_objiterator(void *priv, int flush, const void *ptr, ssize_t len) vdp_objiterator(void *priv, unsigned flush, const void *ptr, ssize_t len)
{ {
return (VDP_bytes(priv, flush ? VDP_FLUSH : VDP_NULL, ptr, len)); return (VDP_bytes(priv, flush ? VDP_FLUSH : VDP_NULL, ptr, len));
} }
......
...@@ -575,7 +575,7 @@ struct ved_foo { ...@@ -575,7 +575,7 @@ struct ved_foo {
}; };
static int v_matchproto_(objiterate_f) static int v_matchproto_(objiterate_f)
ved_objiterate(void *priv, int flush, const void *ptr, ssize_t len) ved_objiterate(void *priv, unsigned flush, const void *ptr, ssize_t len)
{ {
struct ved_foo *foo; struct ved_foo *foo;
const uint8_t *pp; const uint8_t *pp;
......
...@@ -702,15 +702,15 @@ vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo) ...@@ -702,15 +702,15 @@ vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo)
*/ */
static int v_matchproto_(objiterate_f) static int v_matchproto_(objiterate_f)
vbf_objiterator(void *priv, int flush, const void *ptr, ssize_t len) vbf_objiterator(void *priv, unsigned flush, const void *ptr, ssize_t len)
{ {
struct busyobj *bo; struct busyobj *bo;
ssize_t l; ssize_t l;
const uint8_t *ps = ptr; const uint8_t *ps = ptr;
uint8_t *pd; uint8_t *pd;
(void)flush;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
(void)flush;
while (len > 0) { while (len > 0) {
l = len; l = len;
......
...@@ -226,7 +226,7 @@ VRB_Iterate(struct req *req, objiterate_f *func, void *priv) ...@@ -226,7 +226,7 @@ VRB_Iterate(struct req *req, objiterate_f *func, void *priv)
*/ */
static int v_matchproto_(objiterate_f) static int v_matchproto_(objiterate_f)
httpq_req_body_discard(void *priv, int flush, const void *ptr, ssize_t len) httpq_req_body_discard(void *priv, unsigned flush, const void *ptr, ssize_t len)
{ {
(void)priv; (void)priv;
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
*/ */
static int v_matchproto_(objiterate_f) static int v_matchproto_(objiterate_f)
vbf_iter_req_body(void *priv, int flush, const void *ptr, ssize_t l) vbf_iter_req_body(void *priv, unsigned flush, const void *ptr, ssize_t l)
{ {
struct busyobj *bo; struct busyobj *bo;
......
...@@ -246,6 +246,7 @@ sml_iterator(struct worker *wrk, struct objcore *oc, ...@@ -246,6 +246,7 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
ssize_t sl; ssize_t sl;
void *p; void *p;
ssize_t l; ssize_t l;
unsigned u;
obj = sml_getobj(wrk, oc); obj = sml_getobj(wrk, oc);
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
...@@ -256,8 +257,13 @@ sml_iterator(struct worker *wrk, struct objcore *oc, ...@@ -256,8 +257,13 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
if (boc == NULL) { if (boc == NULL) {
VTAILQ_FOREACH_SAFE(st, &obj->list, list, checkpoint) { VTAILQ_FOREACH_SAFE(st, &obj->list, list, checkpoint) {
u = 0;
if (VTAILQ_NEXT(st, list) == NULL)
u |= OBJ_ITER_FINAL;
if (final)
u |= OBJ_ITER_FLUSH;
if (ret == 0 && st->len > 0) if (ret == 0 && st->len > 0)
ret = func(priv, 1, st->ptr, st->len); ret = func(priv, u, st->ptr, st->len);
if (final) { if (final) {
VTAILQ_REMOVE(&obj->list, st, list); VTAILQ_REMOVE(&obj->list, st, list);
sml_stv_free(stv, st); sml_stv_free(stv, st);
...@@ -322,7 +328,10 @@ sml_iterator(struct worker *wrk, struct objcore *oc, ...@@ -322,7 +328,10 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
st = NULL; st = NULL;
Lck_Unlock(&boc->mtx); Lck_Unlock(&boc->mtx);
assert(l > 0 || boc->state == BOS_FINISHED); assert(l > 0 || boc->state == BOS_FINISHED);
ret = func(priv, st != NULL ? final : 1, p, l); u = 0;
if (st == NULL || final)
u |= OBJ_ITER_FLUSH;
ret = func(priv, u, p, l);
if (ret) if (ret)
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment