From be825e5c05c3be646f7ed1ff9325017742e9330e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Thu, 24 Jan 2019 18:28:44 +0100 Subject: [PATCH] CLEANUP: peers: Remove useless statements. When implementing peer_recv_msg() we added the statements reached with a "goto imcomplete" at the end of this function. This statements are executed only when co_getblk() returns something <0. So they are useless for now on, and may be safely removed. The following section wich was responsible of sending any peer protocol messages were reached only when co_getblk() returned 0 (no more message to read). In this case we replace the "goto impcomplete" statement by a "goto send_msgs" to reach this only when peer_recv_msg() returns 0. May be backported as far as 1.5. --- src/peers.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/peers.c b/src/peers.c index 48faa9d85..4a08dd5b6 100644 --- a/src/peers.c +++ b/src/peers.c @@ -2125,27 +2125,20 @@ switchstate: if (reql <= 0) { if (reql == -1) goto switchstate; - goto incomplete; + goto send_msgs; } msg_end += msg_len; if (!peer_treat_awaited_msg(appctx, curpeer, msg_head, &msg_cur, msg_end, msg_len, totl)) goto switchstate; -ignore_msg: + /* skip consumed message */ co_skip(si_oc(si), totl); /* loop on that state to peek next message */ goto switchstate; -incomplete: - /* we get here when a co_getblk() returns <= 0 in reql */ - - if (reql < 0) { - /* there was an error */ - appctx->st0 = PEER_SESS_ST_END; - goto switchstate; - } - +send_msgs: + /* we get here when a peer_recv_msg() returns 0 in reql */ repl = peer_send_msgs(appctx, curpeer); if (repl <= 0) { if (repl == -1)