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