MEDIUM: threads/server: Add a lock per server and atomically update server vars
The server's lock is use, among other things, to lock acces to the active
connection list of a server.
diff --git a/src/server.c b/src/server.c
index 4c70ac4..b6986a9 100644
--- a/src/server.c
+++ b/src/server.c
@@ -761,9 +761,11 @@
{
struct stream *stream, *stream_bck;
+ SPIN_LOCK(SERVER_LOCK, &srv->lock);
list_for_each_entry_safe(stream, stream_bck, &srv->actconns, by_srv)
if (stream->srv_conn == srv)
stream_shutdown(stream, why);
+ SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
}
/* Shutdown all connections of all backup servers of a proxy. The caller must
@@ -1029,7 +1031,6 @@
/* Register changes to be applied asynchronously */
if (LIST_ISEMPTY(&s->update_status))
LIST_ADDQ(&updated_servers, &s->update_status);
-
/* stop going down if the equivalent flag is still present (forced or inherited) */
if (((mode & SRV_ADMF_MAINT) && (s->next_admin & SRV_ADMF_MAINT)) ||
((mode & SRV_ADMF_DRAIN) && (s->next_admin & SRV_ADMF_DRAIN)))
@@ -2021,6 +2022,7 @@
/* Copy default server settings to new server settings. */
srv_settings_cpy(newsrv, &curproxy->defsrv, 0);
+ SPIN_INIT(&newsrv->lock);
cur_arg++;
} else {
newsrv = &curproxy->defsrv;