mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: peers: make peer_session_forceshutdown() use the appctx and not the stream
It was inherited from initial code but we must only manipulate the appctx and never the stream, otherwise we always risk shooting ourselves in the foot.
This commit is contained in:
parent
b21d08e249
commit
81bc3b062b
23
src/peers.c
23
src/peers.c
@ -172,7 +172,7 @@ enum {
|
|||||||
#define PEER_DWNGRD_MINOR_VER 0
|
#define PEER_DWNGRD_MINOR_VER 0
|
||||||
|
|
||||||
struct peers *peers = NULL;
|
struct peers *peers = NULL;
|
||||||
static void peer_session_forceshutdown(struct stream * stream);
|
static void peer_session_forceshutdown(struct appctx *appctx);
|
||||||
|
|
||||||
int intencode(uint64_t i, char **str) {
|
int intencode(uint64_t i, char **str) {
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
@ -669,7 +669,7 @@ switchstate:
|
|||||||
appctx->st1 = PEER_SESS_SC_TRYAGAIN;
|
appctx->st1 = PEER_SESS_SC_TRYAGAIN;
|
||||||
goto switchstate;
|
goto switchstate;
|
||||||
}
|
}
|
||||||
peer_session_forceshutdown(curpeer->stream);
|
peer_session_forceshutdown(curpeer->appctx);
|
||||||
}
|
}
|
||||||
if (maj_ver != (unsigned int)-1 && min_ver != (unsigned int)-1) {
|
if (maj_ver != (unsigned int)-1 && min_ver != (unsigned int)-1) {
|
||||||
if (min_ver == PEER_DWNGRD_MINOR_VER) {
|
if (min_ver == PEER_DWNGRD_MINOR_VER) {
|
||||||
@ -1708,25 +1708,16 @@ static struct applet peer_applet = {
|
|||||||
/*
|
/*
|
||||||
* Use this function to force a close of a peer session
|
* Use this function to force a close of a peer session
|
||||||
*/
|
*/
|
||||||
static void peer_session_forceshutdown(struct stream * stream)
|
static void peer_session_forceshutdown(struct appctx *appctx)
|
||||||
{
|
{
|
||||||
struct appctx *appctx = NULL;
|
|
||||||
struct peer *ps;
|
struct peer *ps;
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i <= 1; i++) {
|
|
||||||
appctx = objt_appctx(stream->si[i].end);
|
|
||||||
if (!appctx)
|
|
||||||
continue;
|
|
||||||
if (appctx->applet != &peer_applet)
|
|
||||||
continue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!appctx)
|
if (!appctx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (appctx->applet != &peer_applet)
|
||||||
|
return;
|
||||||
|
|
||||||
ps = appctx->ctx.peers.ptr;
|
ps = appctx->ctx.peers.ptr;
|
||||||
/* we're killing a connection, we must apply a random delay before
|
/* we're killing a connection, we must apply a random delay before
|
||||||
* retrying otherwise the other end will do the same and we can loop
|
* retrying otherwise the other end will do the same and we can loop
|
||||||
@ -1980,7 +1971,7 @@ static struct task *process_peer_sync(struct task * task)
|
|||||||
/* disconnect all connected peers */
|
/* disconnect all connected peers */
|
||||||
for (ps = peers->remote; ps; ps = ps->next) {
|
for (ps = peers->remote; ps; ps = ps->next) {
|
||||||
if (ps->stream) {
|
if (ps->stream) {
|
||||||
peer_session_forceshutdown(ps->stream);
|
peer_session_forceshutdown(ps->appctx);
|
||||||
ps->stream = NULL;
|
ps->stream = NULL;
|
||||||
ps->appctx = NULL;
|
ps->appctx = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user