-
Notifications
You must be signed in to change notification settings - Fork 396
Stash objcore references until the end of the task to avoid copies #4269
base: master
Are you sure you want to change the base?
Changes from all commits
881bc63
74b45e0
59ca693
96f2da6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,14 +95,6 @@ VRT_synth(VRT_CTX, VCL_INT code, VCL_STRING reason) | |
| return; | ||
| } | ||
|
|
||
| if (reason && !WS_Allocated(ctx->ws, reason, -1)) { | ||
| reason = WS_Copy(ctx->ws, reason, -1); | ||
| if (!reason) { | ||
| VRT_fail(ctx, "Workspace overflow"); | ||
| return; | ||
| } | ||
| } | ||
|
Comment on lines
-98
to
-104
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might not be safe actually: return (synth(200, some_vmod.some_string()));In that case we can't assume a lifetime beyond the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #4269 (comment) regarding this and the next four review comments. |
||
|
|
||
| if (ctx->req == NULL) { | ||
| CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); | ||
| ctx->bo->err_code = (uint16_t)code; | ||
|
|
@@ -459,12 +451,11 @@ VRT_StrandsWS(struct ws *ws, const char *h, VCL_STRANDS s) | |
| } | ||
| } | ||
|
|
||
| if (q == NULL) { | ||
| if (h == NULL) | ||
| return (""); | ||
| if (WS_Allocated(ws, h, -1)) | ||
| return (h); | ||
| } else if (h == NULL && WS_Allocated(ws, q, -1)) { | ||
| if (q == NULL && h == NULL) | ||
| return (""); | ||
| if (q == NULL) | ||
| return (h); | ||
| if (h == NULL) { | ||
|
Comment on lines
-462
to
+458
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise, we can't assume a task lifetime of the arguments. |
||
| for (i++; i < s->n; i++) | ||
| if (s->p[i] != NULL && *s->p[i] != '\0') | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -786,7 +786,7 @@ PARAM_SIMPLE( | |
| /* name */ max_restarts, | ||
| /* type */ uint, | ||
| /* min */ "0", | ||
| /* max */ NULL, | ||
| /* max */ "32766", // (1<<15)-2 #4269 | ||
| /* def */ "4", | ||
| /* units */ "restarts", | ||
| /* descr */ | ||
|
|
@@ -798,7 +798,7 @@ PARAM_SIMPLE( | |
| /* name */ max_retries, | ||
| /* type */ uint, | ||
| /* min */ "0", | ||
| /* max */ NULL, | ||
| /* max */ "65534", // (1<<16)-2 #4269 | ||
| /* def */ "4", | ||
| /* units */ "retries", | ||
|
Comment on lines
798
to
803
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it was up to me, the limit would be 20. |
||
| /* descr */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -646,8 +646,6 @@ xyzzy_concatenate(VRT_CTX, VCL_STRANDS s) | |
|
|
||
| CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); | ||
| r = VRT_StrandsWS(ctx->ws, NULL, s); | ||
| if (r != NULL && *r != '\0') | ||
| AN(WS_Allocated(ctx->ws, r, strlen(r) + 1)); | ||
|
Comment on lines
648
to
-650
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If our concern is coverage for |
||
| return (r); | ||
| } | ||
|
|
||
|
|
@@ -658,8 +656,6 @@ xyzzy_collect(VRT_CTX, VCL_STRANDS s) | |
|
|
||
| CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); | ||
| r = VRT_STRANDS_string(ctx, s); | ||
| if (r != NULL && *r != '\0') | ||
| AN(WS_Allocated(ctx->ws, r, strlen(r) + 1)); | ||
|
Comment on lines
-661
to
-662
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous. |
||
| return (r); | ||
| } | ||
|
|
||
|
|
@@ -692,8 +688,6 @@ xyzzy_sethdr(VRT_CTX, VCL_HEADER hdr, VCL_STRANDS s) | |
| VSLbs(ctx->vsl, SLT_LostHeader, | ||
| TOSTRAND(hdr->what->str)); | ||
| } else { | ||
| if (*b != '\0') | ||
| AN(WS_Allocated(hp->ws, b, strlen(b) + 1)); | ||
|
Comment on lines
-695
to
-696
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous. |
||
| http_Unset(hp, hdr->what); | ||
| http_SetHeader(hp, b); | ||
| } | ||
|
|
@@ -1373,3 +1367,32 @@ xyzzy_log_strands(VRT_CTX, VCL_STRING prefix, VCL_STRANDS subject, VCL_INT nn) | |
| ptr_where(ctx, p), p, n, p, strlen(p) > (unsigned)n ? "..." : ""); | ||
| } | ||
| } | ||
|
|
||
| const void * const priv_task_id_bp = &priv_task_id_bp; | ||
|
|
||
| VCL_VOID | ||
| xyzzy_body_prefix(VRT_CTX, VCL_STRING s) | ||
| { | ||
| struct xyzzy_bp_string *bps; | ||
| struct xyzzy_bp *bp; | ||
| struct vmod_priv *task; | ||
|
|
||
| CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); | ||
|
|
||
| task = VRT_priv_task(ctx, priv_task_id_bp); | ||
| AN(task); | ||
| bp = task->priv; | ||
| if (bp == NULL) { | ||
| bp = WS_Alloc(ctx->ws, (unsigned)sizeof *bp); | ||
| AN(bp); | ||
| task->priv = bp; | ||
| INIT_OBJ(bp, XYZZY_BP_MAGIC); | ||
| VSTAILQ_INIT(&bp->head); | ||
| } | ||
| CHECK_OBJ(bp, XYZZY_BP_MAGIC); | ||
|
|
||
| bps = WS_Alloc(ctx->ws, (unsigned)sizeof *bps); | ||
| AN(bps); | ||
| bps->s = s; | ||
| VSTAILQ_INSERT_TAIL(&bp->head, bps, list); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"discarded objcores" to me sounds like they would be removed from cache.