Use the new storage buffer interface

Previously, we accessed struct storage which is private to steverdores.

Thank you to Martin Blix Grydeland for pointing out this improvement
opportunity.
parent a4357ee7
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "cache/cache_filter.h" #include "cache/cache_filter.h"
#include "cache/cache_objhead.h" #include "cache/cache_objhead.h"
#include "foreign/from_cache_esi_deliver.h" #include "foreign/from_cache_esi_deliver.h"
#include "storage/storage.h"
#include "vend.h" #include "vend.h"
#include "vgz.h" #include "vgz.h"
...@@ -653,11 +652,10 @@ fini_data(struct vdp_ctx *vdx, struct node *node) ...@@ -653,11 +652,10 @@ fini_data(struct vdp_ctx *vdx, struct node *node)
assert(node->type == T_DATA); assert(node->type == T_DATA);
if (node->data.st == NULL) if (node->data.stvbuf == NULL)
return; return;
stv_transient->sml_free(node->data.st); STV_FreeBuf(vdx->wrk, &node->data.stvbuf);
node->data.st = NULL;
} }
/* ============================================================ /* ============================================================
...@@ -827,6 +825,7 @@ push_data(struct vdp_ctx *vdx, struct bytes_tree *tree, ...@@ -827,6 +825,7 @@ push_data(struct vdp_ctx *vdx, struct bytes_tree *tree,
const struct node *node, const struct node *next) const struct node *node, const struct node *next)
{ {
const void *p; const void *p;
size_t len;
enum vdp_action act; enum vdp_action act;
assert(node->type == T_DATA); assert(node->type == T_DATA);
...@@ -841,9 +840,10 @@ push_data(struct vdp_ctx *vdx, struct bytes_tree *tree, ...@@ -841,9 +840,10 @@ push_data(struct vdp_ctx *vdx, struct bytes_tree *tree,
act = (next == NULL) ? VDP_FLUSH : VDP_NULL; act = (next == NULL) ? VDP_FLUSH : VDP_NULL;
p = node->data.ptr; p = node->data.ptr;
if (p == NULL && node->data.len > 0) { if (p == NULL && node->data.len > 0) {
CHECK_OBJ_NOTNULL(node->data.st, STORAGE_MAGIC); p = STV_GetBufPtr(node->data.stvbuf, &len);
p = node->data.st->ptr; assert(len == node->data.len);
} }
if (p == NULL || node->data.len == 0) if (p == NULL || node->data.len == 0)
......
...@@ -140,8 +140,8 @@ struct node_crc { ...@@ -140,8 +140,8 @@ struct node_crc {
struct node_data { struct node_data {
const void *ptr; const void *ptr;
struct storage *st; struct stv_buffer *stvbuf;
ssize_t len; size_t len;
enum vdp_action act; enum vdp_action act;
}; };
......
...@@ -125,7 +125,7 @@ assert_node(const struct node *node, enum check_state check) ...@@ -125,7 +125,7 @@ assert_node(const struct node *node, enum check_state check)
assert_nexus(node, CHK_DELI); assert_nexus(node, CHK_DELI);
AZ(node->nexus.oc); AZ(node->nexus.oc);
} else if (node->type == T_DATA) { } else if (node->type == T_DATA) {
AZ(node->data.st); AZ(node->data.stvbuf);
} }
break; break;
default: default:
......
...@@ -518,6 +518,8 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -518,6 +518,8 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
struct bytes_tree *tree; struct bytes_tree *tree;
struct node *node, *parent; struct node *node, *parent;
struct pesi *pesi; struct pesi *pesi;
void *p;
size_t l;
unsigned refok; unsigned refok;
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC); CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
...@@ -578,9 +580,9 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -578,9 +580,9 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
node->data.ptr = ptr; node->data.ptr = ptr;
} }
else { else {
VSLdbg(vdx, "bytes_add: allocating from transient"); VSLdbg(vdx, "bytes_add: allocating storage buffer");
node->data.st = stv_transient->sml_alloc(stv_transient, len); node->data.stvbuf = STV_AllocBuf(vdx->wrk, stv_transient, len);
if (node->data.st == NULL) { if (node->data.stvbuf == NULL) {
VSLb(vdx->vsl, SLT_Error, "Cannot allocate transient " VSLb(vdx->vsl, SLT_Error, "Cannot allocate transient "
"storage to buffer response data while waiting " "storage to buffer response data while waiting "
"for parallel ESI"); "for parallel ESI");
...@@ -594,12 +596,11 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -594,12 +596,11 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
return (tree->retval); return (tree->retval);
} }
else {
node->data.act = VDP_NULL; node->data.act = VDP_NULL;
AZ(node->data.st->len); p = STV_GetBufPtr(node->data.stvbuf, &l);
assert(node->data.st->space == len); assert(l == (size_t)len);
memcpy(node->data.st->ptr, ptr, len); memcpy(p, ptr, len);
}
} }
node_insert(tree, parent, node); node_insert(tree, parent, node);
......
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