r2969 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Sun Jul 20 11:57:26 CEST 2008
Author: phk
Date: 2008-07-20 11:57:25 +0200 (Sun, 20 Jul 2008)
New Revision: 2969
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_main.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Store the current session in thread private data.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-07-19 12:38:28 UTC (rev 2968)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-07-20 09:57:25 UTC (rev 2969)
@@ -511,6 +511,8 @@
/* cache_main.c */
void THR_Name(const char *name);
+void THR_SetSession(const struct sess *sp);
+const struct sess * THR_GetSession(void);
/* cache_pipe.c */
void PipeSession(struct sess *sp);
@@ -708,8 +710,6 @@
#ifdef WITHOUT_ASSERTS
#define spassert(cond) ((void)(cond))
-#define SPAZ(val) ((void)(val) == 0)
-#define SPAN(val) ((void)(val) != 0)
#else
void panic(const char *, int, const char *,
const struct sess *, const char *, ...);
@@ -720,6 +720,6 @@
panic(__FILE__, __LINE__, __func__, sp, \
"assertion failed: %s\n", #cond); \
} while (0)
+#endif
#define SPAZ(val) spassert((val) == 0)
#define SPAN(val) spassert((val) != 0)
-#endif
Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c 2008-07-19 12:38:28 UTC (rev 2968)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c 2008-07-20 09:57:25 UTC (rev 2969)
@@ -41,6 +41,27 @@
#include "stevedore.h"
/*--------------------------------------------------------------------
+ * Per thread storage for the session currently being processed by
+ * the thread. This is used for panic messages.
+ */
+
+static pthread_key_t sp_key;
+
+void
+THR_SetSession(const struct sess *sp)
+{
+
+ AZ(pthread_setspecific(sp_key, sp));
+}
+
+const struct sess *
+THR_GetSession(void)
+{
+
+ return (pthread_getspecific(sp_key));
+}
+
+/*--------------------------------------------------------------------
* Name threads if our pthreads implementation supports it.
*/
@@ -69,6 +90,8 @@
setbuf(stderr, NULL);
printf("Child starts\n");
+ AZ(pthread_key_create(&sp_key, NULL));
+
THR_Name("cache-main");
CLI_Init();
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-07-19 12:38:28 UTC (rev 2968)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-07-20 09:57:25 UTC (rev 2969)
@@ -323,6 +323,7 @@
struct sess *sess;
CAST_OBJ_NOTNULL(sess, priv, SESS_MAGIC);
+ THR_SetSession(sess);
sess->wrk = w;
CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
@@ -331,6 +332,7 @@
assert(!isnan(w->used));
CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
+ THR_SetSession(NULL);
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list