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";