MAJOR: threads/buffer: Make buffer wait queue thread safe
Adds a global lock to protect the buffer wait queue.
diff --git a/include/proto/applet.h b/include/proto/applet.h
index d9f0ce2..766fc92 100644
--- a/include/proto/applet.h
+++ b/include/proto/applet.h
@@ -88,8 +88,10 @@
}
if (!LIST_ISEMPTY(&appctx->buffer_wait.list)) {
+ SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock);
LIST_DEL(&appctx->buffer_wait.list);
LIST_INIT(&appctx->buffer_wait.list);
+ SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock);
}
pool_free2(pool2_connection, appctx);
diff --git a/include/proto/channel.h b/include/proto/channel.h
index 9e12b5e..83ad0aa 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -440,8 +440,12 @@
if (b_alloc_margin(&chn->buf, margin) != NULL)
return 1;
- if (LIST_ISEMPTY(&wait->list))
+ if (LIST_ISEMPTY(&wait->list)) {
+ SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock);
LIST_ADDQ(&buffer_wq, &wait->list);
+ SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock);
+ }
+
return 0;
}