mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-11 01:26:58 +02:00
[MINOR] add flags to indicate when a stream interface is waiting for space/data
It will soon be required to know when a stream interface is waiting for buffer data or buffer room. Let's add two flags for that.
This commit is contained in:
parent
86491c3164
commit
b0ef735c71
@ -65,6 +65,8 @@ enum {
|
|||||||
SI_FL_NONE = 0x0000, /* nothing */
|
SI_FL_NONE = 0x0000, /* nothing */
|
||||||
SI_FL_EXP = 0x0001, /* timeout has expired */
|
SI_FL_EXP = 0x0001, /* timeout has expired */
|
||||||
SI_FL_ERR = 0x0002, /* a non-recoverable error has occurred */
|
SI_FL_ERR = 0x0002, /* a non-recoverable error has occurred */
|
||||||
|
SI_FL_WAIT_ROOM = 0x0004, /* waiting for space to store incoming data */
|
||||||
|
SI_FL_WAIT_DATA = 0x0008, /* waiting for more data to send */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stream_interface {
|
struct stream_interface {
|
||||||
|
@ -925,7 +925,7 @@ void uxst_process_session(struct task *t, int *next)
|
|||||||
s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
|
s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
|
||||||
s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
|
s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
|
||||||
s->si[0].prev_state = s->si[0].state;
|
s->si[0].prev_state = s->si[0].state;
|
||||||
s->si[0].flags = SI_FL_NONE;
|
s->si[0].flags &= ~(SI_FL_ERR|SI_FL_EXP);
|
||||||
|
|
||||||
/* Trick: if a request is being waiting for the server to respond,
|
/* Trick: if a request is being waiting for the server to respond,
|
||||||
* and if we know the server can timeout, we don't want the timeout
|
* and if we know the server can timeout, we don't want the timeout
|
||||||
|
@ -945,7 +945,8 @@ void process_session(struct task *t, int *next)
|
|||||||
s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
|
s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
|
||||||
s->si[0].prev_state = s->si[0].state;
|
s->si[0].prev_state = s->si[0].state;
|
||||||
s->si[1].prev_state = s->si[1].state;
|
s->si[1].prev_state = s->si[1].state;
|
||||||
s->si[0].flags = s->si[1].flags = SI_FL_NONE;
|
s->si[0].flags &= ~(SI_FL_ERR|SI_FL_EXP);
|
||||||
|
s->si[1].flags &= ~(SI_FL_ERR|SI_FL_EXP);
|
||||||
|
|
||||||
/* Trick: if a request is being waiting for the server to respond,
|
/* Trick: if a request is being waiting for the server to respond,
|
||||||
* and if we know the server can timeout, we don't want the timeout
|
* and if we know the server can timeout, we don't want the timeout
|
||||||
|
@ -86,6 +86,7 @@ int stream_sock_read(int fd) {
|
|||||||
/* Not anymore room to store data. This should theorically
|
/* Not anymore room to store data. This should theorically
|
||||||
* never happen, but better safe than sorry !
|
* never happen, but better safe than sorry !
|
||||||
*/
|
*/
|
||||||
|
si->flags |= SI_FL_WAIT_ROOM;
|
||||||
b->flags |= BF_FULL;
|
b->flags |= BF_FULL;
|
||||||
EV_FD_CLR(fd, DIR_RD);
|
EV_FD_CLR(fd, DIR_RD);
|
||||||
b->rex = TICK_ETERNITY;
|
b->rex = TICK_ETERNITY;
|
||||||
@ -163,6 +164,7 @@ int stream_sock_read(int fd) {
|
|||||||
b->xfer_large = 0;
|
b->xfer_large = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
si->flags |= SI_FL_WAIT_ROOM;
|
||||||
b->flags |= BF_FULL;
|
b->flags |= BF_FULL;
|
||||||
EV_FD_CLR(fd, DIR_RD);
|
EV_FD_CLR(fd, DIR_RD);
|
||||||
b->rex = TICK_ETERNITY;
|
b->rex = TICK_ETERNITY;
|
||||||
@ -348,6 +350,7 @@ int stream_sock_write(int fd) {
|
|||||||
* anything. Theorically we cannot get there, but just in case,
|
* anything. Theorically we cannot get there, but just in case,
|
||||||
* let's disable the write event and pretend we never came there.
|
* let's disable the write event and pretend we never came there.
|
||||||
*/
|
*/
|
||||||
|
si->flags |= SI_FL_WAIT_DATA;
|
||||||
EV_FD_CLR(fd, DIR_WR);
|
EV_FD_CLR(fd, DIR_WR);
|
||||||
b->wex = TICK_ETERNITY;
|
b->wex = TICK_ETERNITY;
|
||||||
goto out_wakeup;
|
goto out_wakeup;
|
||||||
@ -397,6 +400,7 @@ int stream_sock_write(int fd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
si->flags |= SI_FL_WAIT_DATA;
|
||||||
EV_FD_CLR(fd, DIR_WR);
|
EV_FD_CLR(fd, DIR_WR);
|
||||||
b->wex = TICK_ETERNITY;
|
b->wex = TICK_ETERNITY;
|
||||||
goto out_wakeup;
|
goto out_wakeup;
|
||||||
@ -477,6 +481,7 @@ void stream_sock_shutw(struct stream_interface *si)
|
|||||||
return;
|
return;
|
||||||
si->ob->flags |= BF_SHUTW;
|
si->ob->flags |= BF_SHUTW;
|
||||||
si->ob->wex = TICK_ETERNITY;
|
si->ob->wex = TICK_ETERNITY;
|
||||||
|
si->flags &= ~SI_FL_WAIT_DATA;
|
||||||
|
|
||||||
switch (si->state) {
|
switch (si->state) {
|
||||||
case SI_ST_EST:
|
case SI_ST_EST:
|
||||||
@ -487,6 +492,7 @@ void stream_sock_shutw(struct stream_interface *si)
|
|||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case SI_ST_CON:
|
case SI_ST_CON:
|
||||||
|
si->flags &= ~SI_FL_WAIT_ROOM;
|
||||||
/* we may have to close a pending connection, and mark the
|
/* we may have to close a pending connection, and mark the
|
||||||
* response buffer as shutr
|
* response buffer as shutr
|
||||||
*/
|
*/
|
||||||
@ -513,6 +519,7 @@ void stream_sock_shutr(struct stream_interface *si)
|
|||||||
return;
|
return;
|
||||||
si->ib->flags |= BF_SHUTR;
|
si->ib->flags |= BF_SHUTR;
|
||||||
si->ib->rex = TICK_ETERNITY;
|
si->ib->rex = TICK_ETERNITY;
|
||||||
|
si->flags &= ~SI_FL_WAIT_ROOM;
|
||||||
|
|
||||||
if (si->state != SI_ST_EST && si->state != SI_ST_CON)
|
if (si->state != SI_ST_EST && si->state != SI_ST_CON)
|
||||||
return;
|
return;
|
||||||
@ -551,6 +558,8 @@ void stream_sock_data_finish(struct stream_interface *si)
|
|||||||
/* Read not closed, update FD status and timeout for reads */
|
/* Read not closed, update FD status and timeout for reads */
|
||||||
if (ib->flags & (BF_FULL|BF_HIJACK)) {
|
if (ib->flags & (BF_FULL|BF_HIJACK)) {
|
||||||
/* stop reading */
|
/* stop reading */
|
||||||
|
if ((ib->flags & (BF_FULL|BF_HIJACK)) == BF_FULL)
|
||||||
|
si->flags |= SI_FL_WAIT_ROOM;
|
||||||
EV_FD_COND_C(fd, DIR_RD);
|
EV_FD_COND_C(fd, DIR_RD);
|
||||||
ib->rex = TICK_ETERNITY;
|
ib->rex = TICK_ETERNITY;
|
||||||
}
|
}
|
||||||
@ -559,6 +568,7 @@ void stream_sock_data_finish(struct stream_interface *si)
|
|||||||
* everytime we get here, otherwise it would risk never to expire. We only
|
* everytime we get here, otherwise it would risk never to expire. We only
|
||||||
* update it if is was not yet set, or if we already got some read status.
|
* update it if is was not yet set, or if we already got some read status.
|
||||||
*/
|
*/
|
||||||
|
si->flags &= ~SI_FL_WAIT_ROOM;
|
||||||
EV_FD_COND_S(fd, DIR_RD);
|
EV_FD_COND_S(fd, DIR_RD);
|
||||||
if (!(ib->flags & BF_READ_NOEXP) &&
|
if (!(ib->flags & BF_READ_NOEXP) &&
|
||||||
(!tick_isset(ib->rex) || ib->flags & BF_READ_ACTIVITY))
|
(!tick_isset(ib->rex) || ib->flags & BF_READ_ACTIVITY))
|
||||||
@ -572,6 +582,8 @@ void stream_sock_data_finish(struct stream_interface *si)
|
|||||||
if ((ob->flags & BF_EMPTY) ||
|
if ((ob->flags & BF_EMPTY) ||
|
||||||
(ob->flags & (BF_HIJACK|BF_WRITE_ENA)) == 0) {
|
(ob->flags & (BF_HIJACK|BF_WRITE_ENA)) == 0) {
|
||||||
/* stop writing */
|
/* stop writing */
|
||||||
|
if ((ob->flags & (BF_EMPTY|BF_HIJACK|BF_WRITE_ENA)) == (BF_EMPTY|BF_WRITE_ENA))
|
||||||
|
si->flags |= SI_FL_WAIT_DATA;
|
||||||
EV_FD_COND_C(fd, DIR_WR);
|
EV_FD_COND_C(fd, DIR_WR);
|
||||||
ob->wex = TICK_ETERNITY;
|
ob->wex = TICK_ETERNITY;
|
||||||
}
|
}
|
||||||
@ -580,6 +592,7 @@ void stream_sock_data_finish(struct stream_interface *si)
|
|||||||
* everytime we get here, otherwise it would risk never to expire. We only
|
* everytime we get here, otherwise it would risk never to expire. We only
|
||||||
* update it if is was not yet set, or if we already got some write status.
|
* update it if is was not yet set, or if we already got some write status.
|
||||||
*/
|
*/
|
||||||
|
si->flags &= ~SI_FL_WAIT_DATA;
|
||||||
EV_FD_COND_S(fd, DIR_WR);
|
EV_FD_COND_S(fd, DIR_WR);
|
||||||
if (!tick_isset(ob->wex) || ob->flags & BF_WRITE_ACTIVITY) {
|
if (!tick_isset(ob->wex) || ob->flags & BF_WRITE_ACTIVITY) {
|
||||||
ob->wex = tick_add_ifset(now_ms, ob->wto);
|
ob->wex = tick_add_ifset(now_ms, ob->wto);
|
||||||
|
Loading…
Reference in New Issue
Block a user