MINOR: peers: Add a ref to peers section in the peer structure

This change is required to handle asynchrone init of the appctx. It is now
possible to directly get the peers section associated to a peer.
This commit is contained in:
Christopher Faulet 2022-05-12 14:47:52 +02:00
parent aee57fc277
commit 387e79727c
3 changed files with 7 additions and 16 deletions

View File

@ -80,6 +80,7 @@ struct peer {
struct shared_table *tables;
struct server *srv;
struct dcache *dcache; /* dictionary cache */
struct peers *peers; /* associated peer section */
struct peer *next; /* next peer in the list */
};

View File

@ -650,6 +650,7 @@ static struct peer *cfg_peers_add_peer(struct peers *peers,
/* the peers are linked backwards first */
peers->count++;
p->peers = peers;
p->next = peers->remote;
peers->remote = p;
p->conf.file = strdup(file);

View File

@ -443,11 +443,8 @@ static void peers_trace(enum trace_level level, uint64_t mask,
const struct peer *peer = a2;
struct peers *peers = NULL;
if (peer->appctx) {
struct stream *s = appctx_strm(peer->appctx);
peers = strm_fe(s)->parent;
}
if (peer->appctx)
peers = peer->peers;
if (peers)
chunk_appendf(&trace_buf, " %s", peers->local->id);
@ -1037,16 +1034,9 @@ static int peer_prepare_ackmsg(char *msg, size_t size, struct peer_prep_params *
*/
void __peer_session_deinit(struct peer *peer)
{
struct stream *s;
struct peers *peers;
struct peers *peers = peer->peers;
if (!peer->appctx)
return;
s = appctx_strm(peer->appctx);
peers = strm_fe(s)->parent;
if (!peers)
if (!peers || !peer->appctx)
return;
if (peer->appctx->st0 == PEER_SESS_ST_WAITMSG)
@ -2373,8 +2363,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *peer, unsigned char *msg_head,
char **msg_cur, char *msg_end, int msg_len, int totl)
{
struct stream *s = appctx_strm(appctx);
struct peers *peers = strm_fe(s)->parent;
struct peers *peers = peer->peers;
if (msg_head[0] == PEER_MSG_CLASS_CONTROL) {
if (msg_head[1] == PEER_MSG_CTRL_RESYNCREQ) {