diff --git a/src/haproxy.c b/src/haproxy.c index bf982c59c..fcba6cd22 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2375,6 +2375,16 @@ void mworker_pipe_register() fd_want_recv(mworker_pipe[0]); } +/* verifies if some servers' statuses need to be updated and call the update */ +static inline void servers_check_for_updates() +{ + if (!LIST_ISEMPTY(&updated_servers)) { + thread_isolate(); + servers_update_status(); + thread_release(); + } +} + static int sync_poll_loop() { int stop = 0; @@ -2387,12 +2397,6 @@ static int sync_poll_loop() if (!THREAD_NEED_SYNC()) goto exit; - /* *** { */ - /* Put here all sync functions */ - - servers_update_status(); /* Commit server status changes */ - - /* *** } */ exit: stop = (jobs == 0); /* stop when there's nothing left to do */ THREAD_EXIT_SYNC(); @@ -2446,6 +2450,8 @@ static void run_poll_loop() HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit); fd_process_cached_events(); + /* check for server status updates */ + servers_check_for_updates(); /* Synchronize all polling loops */ if (sync_poll_loop()) diff --git a/src/server.c b/src/server.c index 1aedaf88c..f0d510ac8 100644 --- a/src/server.c +++ b/src/server.c @@ -2675,7 +2675,6 @@ struct server *server_find_best_match(struct proxy *bk, char *name, int id, int static void srv_register_update(struct server *srv) { if (LIST_ISEMPTY(&srv->update_status)) { - THREAD_WANT_SYNC(); HA_SPIN_LOCK(UPDATED_SERVERS_LOCK, &updated_servers_lock); if (LIST_ISEMPTY(&srv->update_status)) LIST_ADDQ(&updated_servers, &srv->update_status);