Permalink
Browse files

Turn the snapshot tokens from WS into uintptr_t to make it very

clear that you are not supposed to use them as pointers.
  • Loading branch information...
1 parent bb79466 commit c1cf8d37ee0f07890e9c763de838130862a71c5f @bsdphk bsdphk committed Feb 15, 2017
@@ -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;
@@ -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 */
@@ -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);
@@ -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);
}
@@ -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;
/*--------------------------------------------------------------------*/
@@ -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;
@@ -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())
@@ -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)
@@ -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
@@ -60,7 +60,7 @@ struct v1l {
struct vsl_log *vsl;
ssize_t cnt; /* Flushed byte count */
struct ws *ws;
- void *res;
+ uintptr_t res;
};
/*--------------------------------------------------------------------
@@ -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);
@@ -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);
@@ -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)

0 comments on commit c1cf8d3

Please sign in to comment.