mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 00:57:02 +02:00
CLEANUP: peers: remove a bit of spaghetti to prepare for the next bugfix
We'll need to centralize some pool_alloc()/pool_free() calls in the upcoming fix so before that we need to reduce the number of points by which we leave the critical code.
This commit is contained in:
parent
deaec2fda3
commit
72d6c16df4
92
src/peers.c
92
src/peers.c
@ -600,14 +600,9 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
int totl = 0;
|
int totl = 0;
|
||||||
|
|
||||||
reql = bo_getblk(si->ob, (char *)&c, sizeof(c), totl);
|
reql = bo_getblk(si->ob, (char *)&c, sizeof(c), totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
/* nothing to read */
|
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
|
|
||||||
if ((c & 0x80) || (c == 'D')) {
|
if ((c & 0x80) || (c == 'D')) {
|
||||||
@ -625,13 +620,9 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
pushack = ntohl(netinteger);
|
pushack = ntohl(netinteger);
|
||||||
}
|
}
|
||||||
@ -642,24 +633,16 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
stkey.key = stkey.data.buf;
|
stkey.key = stkey.data.buf;
|
||||||
|
|
||||||
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
stkey.key_len = ntohl(netinteger);
|
stkey.key_len = ntohl(netinteger);
|
||||||
|
|
||||||
reql = bo_getblk(si->ob, stkey.key, stkey.key_len, totl);
|
reql = bo_getblk(si->ob, stkey.key, stkey.key_len, totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
}
|
}
|
||||||
else if (ps->table->table->type == STKTABLE_TYPE_INTEGER) {
|
else if (ps->table->table->type == STKTABLE_TYPE_INTEGER) {
|
||||||
@ -668,13 +651,9 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
stkey.key = &stkey.data.integer;
|
stkey.key = &stkey.data.integer;
|
||||||
|
|
||||||
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
stkey.data.integer = ntohl(netinteger);
|
stkey.data.integer = ntohl(netinteger);
|
||||||
}
|
}
|
||||||
@ -684,26 +663,17 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
stkey.key = stkey.data.buf;
|
stkey.key = stkey.data.buf;
|
||||||
|
|
||||||
reql = bo_getblk(si->ob, (char *)&stkey.data.buf, ps->table->table->key_size, totl);
|
reql = bo_getblk(si->ob, (char *)&stkey.data.buf, ps->table->table->key_size, totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
|
||||||
|
|
||||||
|
totl += reql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read server id */
|
/* read server id */
|
||||||
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
srvid = ntohl(netinteger);
|
srvid = ntohl(netinteger);
|
||||||
|
|
||||||
@ -806,13 +776,9 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
uint32_t netinteger;
|
uint32_t netinteger;
|
||||||
|
|
||||||
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) /* closed or EOL not found */
|
||||||
if (reql == 0) {
|
goto incomplete;
|
||||||
goto incomplete;
|
|
||||||
}
|
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
|
||||||
goto switchstate;
|
|
||||||
}
|
|
||||||
totl += reql;
|
totl += reql;
|
||||||
|
|
||||||
/* Consider remote is up to date with "acked" version */
|
/* Consider remote is up to date with "acked" version */
|
||||||
@ -828,8 +794,16 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
bo_skip(si->ob, totl);
|
bo_skip(si->ob, totl);
|
||||||
|
|
||||||
/* loop on that state to peek next message */
|
/* loop on that state to peek next message */
|
||||||
continue;
|
goto switchstate;
|
||||||
|
|
||||||
incomplete:
|
incomplete:
|
||||||
|
/* we get here when a bo_getblk() returns <= 0 */
|
||||||
|
if (reql < 0) {
|
||||||
|
/* there was an error */
|
||||||
|
si->applet.st0 = PEER_SESSION_END;
|
||||||
|
goto switchstate;
|
||||||
|
}
|
||||||
|
|
||||||
/* Nothing to read, now we start to write */
|
/* Nothing to read, now we start to write */
|
||||||
|
|
||||||
/* Confirm finished or partial messages */
|
/* Confirm finished or partial messages */
|
||||||
|
Loading…
Reference in New Issue
Block a user