/* 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);
#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 *, ...);
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
#include "cache.h"
#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.
*/
setbuf(stderr, NULL);
printf("Child starts\n");
+ AZ(pthread_key_create(&sp_key, NULL));
+
THR_Name("cache-main");
CLI_Init();
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);
assert(!isnan(w->used));
CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
+ THR_SetSession(NULL);
}
/*--------------------------------------------------------------------*/