Commit ff058352 authored by Geoff Simmons's avatar Geoff Simmons

User VRT_blob() to implement .blob().

parent 55e6b1c7
......@@ -604,34 +604,20 @@ vmod_reader_synth(VRT_CTX, struct VPFX(file_reader) *rdr)
VCL_BLOB
vmod_reader_blob(VRT_CTX, struct VPFX(file_reader) *rdr)
{
struct vrt_blob *blob;
VCL_BLOB blob;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(rdr, FILE_READER_MAGIC);
CHECK_OBJ_NOTNULL(rdr->info, FILE_INFO_MAGIC);
if (WS_ReserveSize(ctx->ws, sizeof(*blob)) == 0) {
VRT_fail(ctx, "%s.blob(): cannot reserve workspace",
rdr->obj_name);
return (NULL);
}
blob = (struct vrt_blob *)WS_Reservation(ctx->ws);
blob->type = VMOD_FILE_BLOB_MAGIC;
AZ(pthread_rwlock_rdlock(&rdr->lock));
if (rdr->flags & RDR_ERROR) {
AN(strcmp(rdr->errbuf, NO_ERR));
VRT_fail(ctx, "%s.blob(): %s", rdr->obj_name, rdr->errbuf);
AZ(pthread_rwlock_unlock(&rdr->lock));
WS_Release(ctx->ws, 0);
return (NULL);
}
blob->blob = rdr->addr;
blob->len = rdr->info->len - 1;
ERRCHK(ctx, rdr, "blob", NULL);
AN(rdr->flags & RDR_MAPPED);
AN(rdr->addr);
blob = VRT_blob(ctx, "VMOD file blob()", rdr->addr, rdr->info->len - 1,
VMOD_FILE_BLOB_MAGIC);
AZ(pthread_rwlock_unlock(&rdr->lock));
WS_Release(ctx->ws, sizeof(*blob));
return (blob);
}
......
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