Skip to content

Commit

Permalink
Turn the snapshot tokens from WS into uintptr_t to make it very
Browse files Browse the repository at this point in the history
clear that you are not supposed to use them as pointers.
  • Loading branch information
bsdphk committed Feb 15, 2017
1 parent bb79466 commit c1cf8d3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
8 changes: 4 additions & 4 deletions bin/varnishd/cache/cache.h
Expand Up @@ -468,7 +468,7 @@ struct busyobj {
struct vfp_ctx vfc[1];

struct ws ws[1];
char *ws_bo;
uintptr_t ws_bo;
struct http *bereq0;
struct http *bereq;
struct http *beresp;
Expand Down Expand Up @@ -558,7 +558,7 @@ struct req {
const struct director *director_hint;
struct vcl *vcl;

char *ws_req; /* WS above request data */
uintptr_t ws_req; /* WS above request data */

/* Timestamps */
double t_first; /* First timestamp logged */
Expand Down Expand Up @@ -1062,10 +1062,10 @@ void WS_MarkOverflow(struct ws *ws);
void WS_Release(struct ws *ws, unsigned bytes);
void WS_ReleaseP(struct ws *ws, char *ptr);
void WS_Assert(const struct ws *ws);
void WS_Reset(struct ws *ws, char *p);
void WS_Reset(struct ws *ws, uintptr_t);
void *WS_Alloc(struct ws *ws, unsigned bytes);
void *WS_Copy(struct ws *ws, const void *str, int len);
char *WS_Snapshot(struct ws *ws);
uintptr_t WS_Snapshot(struct ws *ws);
int WS_Overflowed(const struct ws *ws);
void *WS_Printf(struct ws *ws, const char *fmt, ...) __v_printflike(2, 3);

Expand Down
4 changes: 2 additions & 2 deletions bin/varnishd/cache/cache_req.c
Expand Up @@ -201,8 +201,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
return (1);
}

WS_Reset(req->ws, NULL);
WS_Reset(wrk->aws, NULL);
WS_Reset(req->ws, 0);
WS_Reset(wrk->aws, 0);
return (0);
}

Expand Down
4 changes: 2 additions & 2 deletions bin/varnishd/cache/cache_vcl.c
Expand Up @@ -98,7 +98,7 @@ static struct vcl *vcl_active; /* protected by vcl_mtx */
static struct vrt_ctx ctx_cli;
static unsigned handling_cli;
static struct ws ws_cli;
static char *ws_snapshot_cli;
static uintptr_t ws_snapshot_cli;

/*--------------------------------------------------------------------*/

Expand Down Expand Up @@ -1011,7 +1011,7 @@ static void
vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
void *specific, unsigned method, vcl_func_f *func)
{
char *aws;
uintptr_t aws;
struct vsl_log *vsl = NULL;
struct vrt_ctx ctx;

Expand Down
2 changes: 1 addition & 1 deletion bin/varnishd/cache/cache_wrk.c
Expand Up @@ -311,7 +311,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)

CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);

WS_Reset(wrk->aws, NULL);
WS_Reset(wrk->aws, 0);
AZ(wrk->vsl);

if (pp->nidle < pool_reserve())
Expand Down
8 changes: 5 additions & 3 deletions bin/varnishd/cache/cache_ws.c
Expand Up @@ -106,10 +106,12 @@ ws_ClearOverflow(struct ws *ws)
*/

void
WS_Reset(struct ws *ws, char *p)
WS_Reset(struct ws *ws, uintptr_t pp)
{
char *p;

WS_Assert(ws);
p = (char *)pp;
DSL(DBG_WORKSPACE, 0, "WS_Reset(%p, %p)", ws, p);
assert(ws->r == NULL);
if (p == NULL)
Expand Down Expand Up @@ -191,14 +193,14 @@ WS_Printf(struct ws *ws, const char *fmt, ...)
return (p);
}

char *
uintptr_t
WS_Snapshot(struct ws *ws)
{

WS_Assert(ws);
assert(ws->r == NULL);
DSL(DBG_WORKSPACE, 0, "WS_Snapshot(%p) = %p", ws, ws->f);
return (ws->f);
return ((uintptr_t)ws->f);
}

unsigned
Expand Down
4 changes: 2 additions & 2 deletions bin/varnishd/http1/cache_http1_line.c
Expand Up @@ -60,7 +60,7 @@ struct v1l {
struct vsl_log *vsl;
ssize_t cnt; /* Flushed byte count */
struct ws *ws;
void *res;
uintptr_t res;
};

/*--------------------------------------------------------------------
Expand All @@ -72,7 +72,7 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
{
struct v1l *v1l;
unsigned u;
void *res;
uintptr_t res;

CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AZ(wrk->v1l);
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishd/http2/cache_http2_proto.c
Expand Up @@ -690,7 +690,7 @@ h2_new_session(struct worker *wrk, void *arg)
struct sess *sp;
struct h2_sess *h2;
struct h2_req *r2, *r22;
char *wsp;
uintptr_t wsp;

CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC);
Expand Down
2 changes: 1 addition & 1 deletion lib/libvmod_debug/vmod_debug.c
Expand Up @@ -442,7 +442,7 @@ vmod_workspace_overflowed(VRT_CTX, VCL_ENUM which)
return (WS_Overflowed(ws));
}

static char *debug_ws_snap;
static uintptr_t debug_ws_snap;

void
vmod_workspace_snap(VRT_CTX, VCL_ENUM which)
Expand Down

0 comments on commit c1cf8d3

Please sign in to comment.