MINOR: ssl: add build param USE_PRIVATE_CACHE to build cache without shared memory

It removes dependencies with futex or mutex but ssl performances decrease
using nbproc > 1 because switching process force session renegotiation.

This can be useful on small systems which never intend to run in multi-process
mode.
diff --git a/Makefile b/Makefile
index 7453198..f0533a7 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,7 @@
 #   USE_NETFILTER        : enable netfilter on Linux. Automatic.
 #   USE_PCRE             : enable use of libpcre for regex. Recommended.
 #   USE_POLL             : enable poll(). Automatic.
+#   USE_PRIVATE_CACHE    : disable shared memory cache of ssl sessions.
 #   USE_REGPARM          : enable regparm optimization. Recommended on x86.
 #   USE_SEPOLL           : enable speculative epoll(). Automatic.
 #   USE_STATIC_PCRE      : enable static libpcre. Recommended.
@@ -476,12 +477,16 @@
 OPTIONS_CFLAGS  += -DUSE_OPENSSL
 OPTIONS_LDFLAGS += -lssl -lcrypto
 OPTIONS_OBJS  += src/ssl_sock.o src/shctx.o
+ifneq ($(USE_PRIVATE_CACHE),)
+OPTIONS_CFLAGS  += -DUSE_PRIVATE_CACHE
+else
 ifneq ($(USE_FUTEX),)
 OPTIONS_CFLAGS  += -DUSE_SYSCALL_FUTEX
 else
 OPTIONS_LDFLAGS += -lpthread
 endif
 endif
+endif
 
 ifneq ($(USE_PCRE),)
 # PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
diff --git a/include/proto/shctx.h b/include/proto/shctx.h
index 862f6a0..6705664 100644
--- a/include/proto/shctx.h
+++ b/include/proto/shctx.h
@@ -56,7 +56,8 @@
 /* Allocate shared memory context.
  * size is maximum cached sessions.
  *      if set less or equal to 0, SHCTX_DEFAULT_SIZE is used.
- * use_shared_memory is set to 1 to use a mapped share memory
+ * set use_shared_memory to 1 to use a mapped shared memory insteed
+ * of private. (ignored if compiled whith USE_PRIVATE_CACHE=1)
  * Returns: -1 on alloc failure, size if it performs context alloc,
  * and 0 if cache is already allocated */
 int shared_context_init(int size, int use_shared_memory);
diff --git a/src/shctx.c b/src/shctx.c
index 23992a6..2db8f79 100644
--- a/src/shctx.c
+++ b/src/shctx.c
@@ -12,6 +12,7 @@
  */
 
 #include <sys/mman.h>
+#ifndef USE_PRIVATE_CACHE
 #ifdef USE_SYSCALL_FUTEX
 #include <unistd.h>
 #ifndef u32
@@ -22,6 +23,7 @@
 #else /* USE_SYSCALL_FUTEX */
 #include <pthread.h>
 #endif /* USE_SYSCALL_FUTEX */
+#endif
 
 #include "ebmbtree.h"
 #include "proto/shctx.h"
@@ -38,23 +40,32 @@
 
 
 struct shared_context {
+#ifndef USE_PRIVATE_CACHE
 #ifdef USE_SYSCALL_FUTEX
 	unsigned int waiters;
 #else /* USE_SYSCALL_FUTEX */
 	pthread_mutex_t mutex;
 #endif
+#endif
 	struct shared_session active;
 	struct shared_session free;
 };
 
 /* Static shared context */
 static struct shared_context *shctx = NULL;
+#ifndef USE_PRIVATE_CACHE
 static int use_shared_mem = 0;
+#endif
 
 /* Callbacks */
 static void (*shared_session_new_cbk)(unsigned char *session, unsigned int session_len, long cdate);
 
 /* Lock functions */
+#ifdef USE_PRIVATE_CACHE
+#define shared_context_lock(v)
+#define shared_context_unlock(v)
+
+#else
 #ifdef USE_SYSCALL_FUTEX
 #if defined (__i586__) || defined (__x86_64__)
 static inline unsigned int xchg(unsigned int *ptr, unsigned int x)
@@ -141,6 +152,7 @@
 #define shared_context_unlock(v) if (use_shared_mem) pthread_mutex_unlock(&shctx->mutex)
 
 #endif
+#endif
 
 /* List Macros */
 
@@ -365,9 +377,11 @@
 int shared_context_init(int size, int shared)
 {
 	int i;
+#ifndef USE_PRIVATE_CACHE
 #ifndef USE_SYSCALL_FUTEX
 	pthread_mutexattr_t attr;
 #endif /* USE_SYSCALL_FUTEX */
+#endif
 	struct shared_session *prev,*cur;
 	int maptype = MAP_PRIVATE;
 
@@ -377,8 +391,10 @@
 	if (size<=0)
 		size = SHCTX_DEFAULT_SIZE;
 
+#ifndef USE_PRIVATE_CACHE
 	if (shared)
 		maptype = MAP_SHARED;
+#endif
 
 	shctx = (struct shared_context *)mmap(NULL, sizeof(struct shared_context)+(size*sizeof(struct shared_session)),
 	                                      PROT_READ | PROT_WRITE, maptype | MAP_ANON, -1, 0);
@@ -387,6 +403,7 @@
 		return -1;
 	}
 
+#ifndef USE_PRIVATE_CACHE
 #ifdef USE_SYSCALL_FUTEX
 	shctx->waiters = 0;
 #else
@@ -396,6 +413,7 @@
 #endif
 	if (maptype == MAP_SHARED)
 		use_shared_mem = 1;
+#endif
 
 	memset(&shctx->active.key, 0, sizeof(struct ebmb_node));
 	memset(&shctx->free.key, 0, sizeof(struct ebmb_node));