Commit d0fd842e authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: - corrected the termination condition

	- now logging the varnish instance name
	- some code cleanup
parent 85e445a2
...@@ -685,7 +685,7 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, ...@@ -685,7 +685,7 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
(void) bitmap; (void) bitmap;
if (term && htbl.open == 0) if (term && htbl.open == 0)
return 1; return 0;
if (wrk_running < config.nworkers) { if (wrk_running < config.nworkers) {
wrk_running = WRK_Running(); wrk_running = WRK_Running();
...@@ -701,7 +701,7 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, ...@@ -701,7 +701,7 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
switch (tag) { switch (tag) {
case SLT_ReqStart: case SLT_ReqStart:
if (term) return(0); if (term) return 0;
htbl.seen++; htbl.seen++;
err = Parse_ReqStart(ptr, len, &xid); err = Parse_ReqStart(ptr, len, &xid);
...@@ -808,7 +808,7 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, ...@@ -808,7 +808,7 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
} }
pptr = ptr; pptr = ptr;
return(0); return 0;
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -833,17 +833,14 @@ vsl_diag(void *priv, const char *fmt, ...) ...@@ -833,17 +833,14 @@ vsl_diag(void *priv, const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void static const char *
init_pthread_attrs(void) vsm_name(struct VSM_data *vd)
{ {
AZ(pthread_mutexattr_init(&attr_lock)); const char * name = VSM_Name(vd);
AZ(pthread_condattr_init(&attr_cond)); if (name && *name)
return name;
// important to make mutex/cv efficient else
AZ(pthread_mutexattr_setpshared(&attr_lock, return "default";
PTHREAD_PROCESS_PRIVATE));
AZ(pthread_condattr_setpshared(&attr_cond,
PTHREAD_PROCESS_PRIVATE));
} }
void void
...@@ -854,7 +851,12 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig) ...@@ -854,7 +851,12 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig)
pthread_t monitor; pthread_t monitor;
struct passwd *pw; struct passwd *pw;
init_pthread_attrs(); AZ(pthread_mutexattr_init(&attr_lock));
AZ(pthread_condattr_init(&attr_cond));
// important to make mutex/cv efficient
AZ(pthread_mutexattr_setpshared(&attr_lock, PTHREAD_PROCESS_PRIVATE));
AZ(pthread_condattr_setpshared(&attr_cond, PTHREAD_PROCESS_PRIVATE));
MON_StatsInit(); MON_StatsInit();
LOG_Log0(LOG_INFO, "Worker process starting"); LOG_Log0(LOG_INFO, "Worker process starting");
...@@ -902,6 +904,7 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig) ...@@ -902,6 +904,7 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig)
VSM_Diag(vd, vsl_diag, NULL); VSM_Diag(vd, vsl_diag, NULL);
if (VSL_Open(vd, 1)) if (VSL_Open(vd, 1))
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
LOG_Log(LOG_INFO, "Reading varnish instance %s", vsm_name(vd));
/* Only read the VSL tags relevant to tracking */ /* Only read the VSL tags relevant to tracking */
assert(VSL_Arg(vd, 'i', TRACK_TAGS) > 0); assert(VSL_Arg(vd, 'i', TRACK_TAGS) > 0);
...@@ -965,6 +968,11 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig) ...@@ -965,6 +968,11 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig)
continue; continue;
} }
if (term)
LOG_Log0(LOG_INFO, "Termination signal received");
else if (endless)
LOG_Log0(LOG_WARNING, "Varnish log closed");
WRK_Halt(); WRK_Halt();
WRK_Shutdown(); WRK_Shutdown();
AZ(MQ_GlobalShutdown()); AZ(MQ_GlobalShutdown());
......
...@@ -22,7 +22,7 @@ CMD="../trackrdrd -D -f varnish.binlog -l - -d -c test.conf" ...@@ -22,7 +22,7 @@ CMD="../trackrdrd -D -f varnish.binlog -l - -d -c test.conf"
# the user running it # the user running it
CKSUM=$( $CMD | sed -e 's/\(initializing\) \(.*\)/\1/' | sed -e 's/\(Running as\) \([a-zA-Z0-9]*\)$/\1/' | grep -v 'Not running as root' | cksum) CKSUM=$( $CMD | sed -e 's/\(initializing\) \(.*\)/\1/' | sed -e 's/\(Running as\) \([a-zA-Z0-9]*\)$/\1/' | grep -v 'Not running as root' | cksum)
if [ "$CKSUM" != '1346049411 234027' ]; then if [ "$CKSUM" != '2485830008 234066' ]; then
echo "ERROR: Regression test incorrect cksum: $CKSUM" echo "ERROR: Regression test incorrect cksum: $CKSUM"
exit 1 exit 1
fi fi
......
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