]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: Wait for sync task ack when a resynchro is finished
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Apr 2024 08:53:46 +0000 (10:53 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 25 Apr 2024 16:29:57 +0000 (18:29 +0200)
When a learning process is finished, partially or not, the event must be
processed by the sync task. It is important for the peer applet to wait in
this case, especially if the same peer is teaching to another peer, to be
sure to send the right resync finished message (full or partial).

Thanks to the previous patch, we can set PEER_F_WAIT_SYNCTASK_ACK flag on
the peer when a PEER_MSG_CTRL_RESYNCPARTIAL or PEER_MSG_CTRL_RESYNCFINISHED
message is received to be sure to stop the processing. Of course, we must
also take care to wake the peer up after having acknowledged the learn
status from the sync task.

This patch depends on the commit "BUG/MEDIUM: peers: Wait for sync task ack
when a resynchro is finished". Both must be backported if commit 9425aeaffb
("BUG/MAJOR: peers: Update peers section state from a thread-safe manner")
is backported.

src/peers.c

index 218d48ddeab6f33332445c45a4d97fe91a69d6a7..6abfca24f6e5f9b06af4eb0b6bd1d33fd8552b2c 100644 (file)
@@ -2510,7 +2510,7 @@ static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *pee
                                    NULL, &msg_head[1], peers->local->id, peer->id);
                        if (peer->flags & PEER_F_LEARN_PROCESS) {
                                peer->flags &= ~PEER_F_LEARN_PROCESS;
-                               peer->flags |= PEER_F_LEARN_FINISHED;
+                               peer->flags |= (PEER_F_LEARN_FINISHED|PEER_F_WAIT_SYNCTASK_ACK);
                                task_wakeup(peers->sync_task, TASK_WOKEN_MSG);
                        }
                        peer->confirm++;
@@ -2520,7 +2520,7 @@ static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *pee
                                    NULL, &msg_head[1], peers->local->id, peer->id);
                        if (peer->flags & PEER_F_LEARN_PROCESS) {
                                peer->flags &= ~PEER_F_LEARN_PROCESS;
-                               peer->flags |= (PEER_F_LEARN_FINISHED|PEER_F_LEARN_NOTUP2DATE);
+                               peer->flags |= (PEER_F_LEARN_FINISHED|PEER_F_LEARN_NOTUP2DATE|PEER_F_WAIT_SYNCTASK_ACK);
                                task_wakeup(peers->sync_task, TASK_WOKEN_MSG);
                        }
                        peer->confirm++;
@@ -3393,6 +3393,8 @@ static void __process_peer_learn_status(struct peers *peers, struct peer *peer)
        }
        peer->flags &= ~(PEER_F_LEARN_ASSIGN|PEER_F_LEARN_PROCESS|PEER_F_LEARN_FINISHED);
        peers->flags &= ~(PEERS_F_RESYNC_ASSIGN|PEERS_F_RESYNC_PROCESS);
+
+       appctx_wakeup(peer->appctx);
 }
 
 static void __process_peer_state(struct peers *peers, struct peer *peer)