BUG/MEDIUM: proxy: ensure pause_proxy() and resume_proxy() own PROXY_LOCK
There was a race involving hlua_proxy_* functions
and some proxy management functions.
pause_proxy() and resume_proxy() can be used directly from lua code,
but that could lead to some race as lua code didn't make sure PROXY_LOCK
was owned before calling the proxy functions.
This patch makes sure it won't happen again elsewhere in the code
by locking PROXY_LOCK directly in resume and pause proxy functions
so that it's not the caller's responsibility anymore.
(based on stop_proxy() behavior that was already safe prior to the patch)
This should be backported to stable series.
Note that the API will likely differ < 2.4
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index 5907d48..0046e9e 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -1311,6 +1311,7 @@
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ /* safe to call without PROXY_LOCK - pause_proxy takes it */
pause_proxy(px);
return 0;
}
@@ -1320,6 +1321,7 @@
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ /* safe to call without PROXY_LOCK - resume_proxy takes it */
resume_proxy(px);
return 0;
}
@@ -1329,6 +1331,7 @@
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ /* safe to call without PROXY_LOCK - stop_proxy takes it */
stop_proxy(px);
return 0;
}