Commit db6d2798 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: Fixed off-by-one error in parse.c/Parse_ReqStart

           Mutexing increment of tbl.open after ReqStart
vcl: do not log the URL /ts-rcv
parent 4e8564cc
...@@ -103,6 +103,7 @@ MON_StatsUpdate(stats_update_t update) ...@@ -103,6 +103,7 @@ MON_StatsUpdate(stats_update_t update)
break; break;
case STATS_OCCUPANCY: case STATS_OCCUPANCY:
tbl.open++;
if (tbl.open + tbl.done > tbl.occ_hi) if (tbl.open + tbl.done > tbl.occ_hi)
tbl.occ_hi = tbl.open + tbl.done; tbl.occ_hi = tbl.open + tbl.done;
break; break;
......
...@@ -56,7 +56,7 @@ int ...@@ -56,7 +56,7 @@ int
Parse_ReqStart(const char *ptr, int len, unsigned *xid) Parse_ReqStart(const char *ptr, int len, unsigned *xid)
{ {
int i; int i;
for (i = len; ptr[i] != ' '; i--) for (i = len-1; ptr[i] != ' '; i--)
if (i == 0) if (i == 0)
return EINVAL; return EINVAL;
return Parse_XID(&ptr[i+1], len-i-1, xid); return Parse_XID(&ptr[i+1], len-i-1, xid);
......
...@@ -122,6 +122,20 @@ static char ...@@ -122,6 +122,20 @@ static char
sprintf(errmsg, "ReqStart %s: returned XID=%d", REQSTART, xid); sprintf(errmsg, "ReqStart %s: returned XID=%d", REQSTART, xid);
mu_assert(errmsg, xid == 1253687608); mu_assert(errmsg, xid == 1253687608);
#define REQSTART2 "127.0.0.1 56431 18217014 "
err = Parse_ReqStart(REQSTART2, strlen(REQSTART2)-1, &xid);
sprintf(errmsg, "ReqStart %s: %s", REQSTART2, strerror(err));
mu_assert(errmsg, err == 0);
sprintf(errmsg, "ReqStart %s: returned XID=%d", REQSTART2, xid);
mu_assert(errmsg, xid == 18217014);
#define REQSTART3 "127.0.0.1 53890 18228551 "
err = Parse_ReqStart(REQSTART3, strlen(REQSTART3)-1, &xid);
sprintf(errmsg, "ReqStart %s: %s", REQSTART3, strerror(err));
mu_assert(errmsg, err == 0);
sprintf(errmsg, "ReqStart %s: returned XID=%d", REQSTART3, xid);
mu_assert(errmsg, xid == 18228551);
err = Parse_ReqStart("1253687608", 10, &xid); err = Parse_ReqStart("1253687608", 10, &xid);
sprintf(errmsg, "ReqStart 1253687608: expected EINVAL, got %d", err); sprintf(errmsg, "ReqStart 1253687608: expected EINVAL, got %d", err);
mu_assert(errmsg, err == EINVAL); mu_assert(errmsg, err == EINVAL);
......
...@@ -126,7 +126,7 @@ static inline dataentry ...@@ -126,7 +126,7 @@ static inline dataentry
entry->end = strlen(entry->data); entry->end = strlen(entry->data);
if (entry->end > tbl.data_hi) if (entry->end > tbl.data_hi)
tbl.data_hi = entry->end; tbl.data_hi = entry->end;
tbl.open++; tbl.seen++;
MON_StatsUpdate(STATS_OCCUPANCY); MON_StatsUpdate(STATS_OCCUPANCY);
return entry; return entry;
...@@ -185,7 +185,6 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, ...@@ -185,7 +185,6 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
AZ(err); AZ(err);
LOG_Log(LOG_DEBUG, "%s: XID=%d", VSL_tags[tag], xid); LOG_Log(LOG_DEBUG, "%s: XID=%d", VSL_tags[tag], xid);
tbl.seen++;
(void) insert(xid, tag, fd); (void) insert(xid, tag, fd);
break; break;
......
import std; # VMOD std *must* be imported by the including VCL
import urlcode; import urlcode;
sub vcl_recv_track { sub vcl_recv_track {
...@@ -9,8 +9,10 @@ sub vcl_recv_track { ...@@ -9,8 +9,10 @@ sub vcl_recv_track {
req.url !~ req.url !~
"^/(?:ts-processor|[^/]+(?:/api)?/internal/status)|\.(?:gif|jpe?g|swf|png|css|js|ico)$" "^/(?:ts-processor|[^/]+(?:/api)?/internal/status)|\.(?:gif|jpe?g|swf|png|css|js|ico)$"
) { ) {
if (! req.url ~ "^/ts-rcv") {
std.log("track " + req.xid + std.log("track " + req.xid +
" url=" + urlcode.encode(req.url)); " url=" + urlcode.encode(req.url));
}
if (req.http.Cookie) { if (req.http.Cookie) {
std.log("track " + req.xid + " http_Cookie=" std.log("track " + req.xid + " http_Cookie="
+ urlcode.encode(req.http.Cookie)); + urlcode.encode(req.http.Cookie));
......
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