MAJOR: threads/buffer: Make buffer wait queue thread safe

Adds a global lock to protect the buffer wait queue.
diff --git a/src/buffer.c b/src/buffer.c
index 83e4e9e..e892d1e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -33,6 +33,9 @@
 
 /* list of objects waiting for at least one buffer */
 struct list buffer_wq = LIST_HEAD_INIT(buffer_wq);
+#ifdef USE_THREAD
+HA_SPINLOCK_T buffer_wq_lock;
+#endif
 
 /* this buffer is always the same size as standard buffers and is used for
  * swapping data inside a buffer.
@@ -72,6 +75,8 @@
 	if (global.tune.buf_limit)
 		pool2_buffer->limit = global.tune.buf_limit;
 
+	SPIN_INIT(&buffer_wq_lock);
+
 	buffer = pool_refill_alloc(pool2_buffer, pool2_buffer->minavail - 1);
 	if (!buffer)
 		return 0;