]> err.no Git - varnish/commitdiff
Move the logging of state engine states to use the diag_bitmap
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 18 Feb 2008 11:47:55 +0000 (11:47 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 18 Feb 2008 11:47:55 +0000 (11:47 +0000)
instead of #ifdef DIAGNOSTICS for control.

Also reduce VSL mutex cost by 50% for the common case where we have
a worker thread: We did a WSL_Flush() followed by a VSL(), doing a
WSL() before the WSL_FLush saves one VSL mutex op.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2509 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_center.c

index 94b52f1aa16b8f599b75561fdb57c80485fcd5d9..a89e10d064192453ed528a18704750576cc7dff2 100644 (file)
@@ -868,6 +868,21 @@ cnt_start(struct sess *sp)
  *
  */
 
+static void
+cnt_diag(struct sess *sp, const char *state)
+{
+       if (sp->wrk != NULL) {
+               WSL(sp->wrk, SLT_Debug, sp->id,
+                   "thr %p STP_%s sp %p obj %p vcl %p",
+                   pthread_self(), state, sp, sp->obj, sp->vcl);
+               WSL_Flush(sp->wrk);
+       } else {
+               VSL(SLT_Debug, sp->id,
+                   "thr %p STP_%s sp %p obj %p vcl %p",
+                   pthread_self(), state, sp, sp->obj, sp->vcl);
+       }
+}
+
 void
 CNT_Session(struct sess *sp)
 {
@@ -892,22 +907,12 @@ CNT_Session(struct sess *sp)
                CHECK_OBJ_ORNULL(sp->director, DIRECTOR_MAGIC);
 
                switch (sp->step) {
-#ifdef DIAGNOSTICS
-#define STEP(l,u) \
-                   case STP_##u: \
-                       if (sp->wrk) \
-                               WSL_Flush(sp->wrk); \
-                       VSL(SLT_Debug, sp->id, \
-                           "thr %p STP_%s sp %p obj %p vcl %p", \
-                           pthread_self(), #u, sp, sp->obj, sp->vcl); \
-                       done = cnt_##l(sp); \
-                       break;
-#else
 #define STEP(l,u) \
                    case STP_##u: \
+                       if (params->diag_bitmap & 0x01) \
+                               cnt_diag(sp, #u); \
                        done = cnt_##l(sp); \
                        break;
-#endif
 #include "steps.h"
 #undef STEP
                default:        INCOMPL();