]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Add flags to report the peer state to the resync task
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 22 Mar 2024 13:34:21 +0000 (14:34 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 16 Apr 2024 08:29:21 +0000 (10:29 +0200)
As the previous patch, this patch is also part of the refactoring of peer
locking mechanisme. Here we add flags to represent a transitional state for
a peer. It will be the resync task responsibility to update the peers state
accordingly.

A peer may be in 4 transitional states:

  * accepted : a connection was accepted from a peer
  * connected: a connection to a peer was established
  * release  : a peer session was released
  * renewed  : a peer session was released because it was replaced by a new
               one. Concretly, this will be equivalent to released+accepted

If none of these flags is set, it means the transition, if any, was
processed by the resync task, or no transition happened.

src/peers.c

index b8aae16780e72f8362b118a373f6bb6c7179ddc7..5a4a59452819c90cb208a84ebc41ee0f6371cfdb 100644 (file)
 #define PEER_F_LEARN_PROCESS        0x00000020 /* Learn from peer was started */
 #define PEER_F_LEARN_FINISHED       0x00000040 /* Learn from peer fully finished */
 #define PEER_F_LEARN_NOTUP2DATE     0x00000080 /* Learn from peer finished but peer is not up to date */
+#define PEER_F_ST_ACCEPTED          0x00000100 /* Used to set a peer in accepted state.  */
+#define PEER_F_ST_CONNECTED         0x00000200 /* Used to set a peer in connected state.  */
+#define PEER_F_ST_RENEWED           0x00000400 /* Used to set a peer in accepted state and old connection was replaced.  */
+#define PEER_F_ST_RELEASED          0x00000800 /* Used to set a peer in released state.  */
 #define PEER_F_ALIVE                0x20000000 /* Used to flag a peer a alive. */
 #define PEER_F_HEARTBEAT            0x40000000 /* Heartbeat message to send. */
 #define PEER_F_DWNGRD               0x80000000 /* When this flag is enabled, we must downgrade the supported version announced during peer sessions. */
 
 #define PEER_TEACH_RESET            ~(PEER_F_TEACH_PROCESS|PEER_F_TEACH_FINISHED) /* PEER_F_TEACH_COMPLETE should never be reset */
 #define PEER_LEARN_RESET            ~(PEER_F_LEARN_ASSIGN|PEER_F_LEARN_PROCESS|PEER_F_LEARN_FINISHED|PEER_F_LEARN_NOTUP2DATE)
+#define PEER_STATE_RESET            ~(PEER_F_ST_ACCEPTED|PEER_F_ST_CONNECTED|PEER_F_ST_RENEWED|PEER_F_ST_RELEASED)
+
 
 #define PEER_RESYNC_TIMEOUT         5000 /* 5 seconds */
 #define PEER_RECONNECT_TIMEOUT      5000 /* 5 seconds */