MEDIUM: buffer: remove the buffer_wq lock

This lock was only needed to protect the buffer_wq list, but now we have
the mt_list for this. This patch simply turns the buffer_wq list to an
mt_list and gets rid of the lock.

It's worth noting that the whole buffer_wait thing still looks totally
wrong especially in a threaded context: the wakeup_cb() callback is
called synchronously from any thread and may end up calling some
connection code that was not expected to run on a given thread. The
whole thing should probably be reworked to use tasklets instead and be
a bit more centralized.
diff --git a/include/common/buffer.h b/include/common/buffer.h
index 0d44ec8..779186f 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -40,11 +40,11 @@
 struct buffer_wait {
 	void *target;              /* The waiting object that should be woken up */
 	int (*wakeup_cb)(void *);  /* The function used to wake up the <target>, passed as argument */
-	struct list list;          /* Next element in the <buffer_wq> list */
+	struct mt_list list;        /* Next element in the <buffer_wq> list */
 };
 
 extern struct pool_head *pool_head_buffer;
-extern struct list buffer_wq;
+extern struct mt_list buffer_wq;
 __decl_hathreads(extern HA_SPINLOCK_T buffer_wq_lock);
 
 int init_buffer();
@@ -203,13 +203,8 @@
 
 static inline void offer_buffers(void *from, unsigned int threshold)
 {
-	if (LIST_ISEMPTY(&buffer_wq))
-		return;
-
-	HA_SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock);
-	if (!LIST_ISEMPTY(&buffer_wq))
+	if (!MT_LIST_ISEMPTY(&buffer_wq))
 		__offer_buffer(from, threshold);
-	HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock);
 }
 
 
diff --git a/include/common/hathreads.h b/include/common/hathreads.h
index daef3a4..afd52d0 100644
--- a/include/common/hathreads.h
+++ b/include/common/hathreads.h
@@ -542,7 +542,6 @@
 	STK_SESS_LOCK,
 	APPLETS_LOCK,
 	PEER_LOCK,
-	BUF_WQ_LOCK,
 	STRMS_LOCK,
 	SSL_LOCK,
 	SSL_GEN_CERTS_LOCK,
@@ -661,7 +660,6 @@
 	case STK_SESS_LOCK:        return "STK_SESS";
 	case APPLETS_LOCK:         return "APPLETS";
 	case PEER_LOCK:            return "PEER";
-	case BUF_WQ_LOCK:          return "BUF_WQ";
 	case STRMS_LOCK:           return "STRMS";
 	case SSL_LOCK:             return "SSL";
 	case SSL_GEN_CERTS_LOCK:   return "SSL_GEN_CERTS";
diff --git a/include/proto/applet.h b/include/proto/applet.h
index b4e9396..31b4d90 100644
--- a/include/proto/applet.h
+++ b/include/proto/applet.h
@@ -75,7 +75,7 @@
 		}
 		appctx->t->process = task_run_applet;
 		appctx->t->context = appctx;
-		LIST_INIT(&appctx->buffer_wait.list);
+		MT_LIST_INIT(&appctx->buffer_wait.list);
 		appctx->buffer_wait.target = appctx;
 		appctx->buffer_wait.wakeup_cb = appctx_buf_available;
 		_HA_ATOMIC_ADD(&nb_applets, 1);
@@ -87,12 +87,8 @@
 static inline void __appctx_free(struct appctx *appctx)
 {
 	task_destroy(appctx->t);
-	if (!LIST_ISEMPTY(&appctx->buffer_wait.list)) {
-		HA_SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock);
-		LIST_DEL(&appctx->buffer_wait.list);
-		LIST_INIT(&appctx->buffer_wait.list);
-		HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock);
-	}
+	if (MT_LIST_ADDED(&appctx->buffer_wait.list))
+		MT_LIST_DEL(&appctx->buffer_wait.list);
 
 	pool_free(pool_head_appctx, appctx);
 	_HA_ATOMIC_SUB(&nb_applets, 1);
diff --git a/include/proto/channel.h b/include/proto/channel.h
index 5411a74..88f4f25 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -855,11 +855,8 @@
 	if (b_alloc_margin(&chn->buf, margin) != NULL)
 		return 1;
 
-	if (LIST_ISEMPTY(&wait->list)) {
-		HA_SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock);
-		LIST_ADDQ(&buffer_wq, &wait->list);
-		HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock);
-	}
+	if (!MT_LIST_ADDED(&wait->list))
+		MT_LIST_ADDQ(&buffer_wq, &wait->list);
 
 	return 0;
 }