/* rfc2616.c */
int RFC2616_cache_policy(struct sess *sp, struct http *hp);
-#define LOCKSHM(foo) AZ(pthread_mutex_lock(foo))
-#define UNLOCKSHM(foo) AZ(pthread_mutex_unlock(foo))
-
#if 1
#define MTX pthread_mutex_t
#define MTX_INIT(foo) AZ(pthread_mutex_init(foo, NULL))
#include "heritage.h"
+#define LOCKSHM(foo) \
+ do { \
+ if (pthread_mutex_trylock(foo)) { \
+ AZ(pthread_mutex_lock(foo)); \
+ VSL_stats->shm_cont++; \
+ } \
+ } while (0);
+
+#define UNLOCKSHM(foo) AZ(pthread_mutex_unlock(foo))
+
#ifndef MAP_HASSEMAPHORE
#define MAP_HASSEMAPHORE 0 /* XXX Linux */
#endif
shmlog_tags.h \
stat_field.h \
stats.h \
- tree.h \
varnish/assert.h \
varnishapi.h \
vcl.h \
MAC_STAT(sess_pipeline, uint64_t, "u", "Session Pipeline")
MAC_STAT(sess_readahead, uint64_t, "u", "Session Read Ahead")
MAC_STAT(sess_herd, uint64_t, "u", "Session herd")
+
+MAC_STAT(shm_cont, uint64_t, "u", "SHM MTX contention")