*/
if (buffer_not_empty(&req->buf) && msg->msg_state < HTTP_MSG_ERROR) {
if ((txn->flags & TX_NOT_FIRST) &&
- unlikely((req->flags & BF_FULL) ||
+ unlikely(channel_full(req) ||
bi_end(&req->buf) < b_ptr(&req->buf, msg->next) ||
bi_end(&req->buf) > req->buf.data + req->buf.size - global.tune.maxrewrite)) {
if (req->buf.o) {
* keep-alive requests.
*/
if ((txn->flags & TX_NOT_FIRST) &&
- unlikely((s->rep->flags & BF_FULL) ||
+ unlikely(channel_full(s->rep) ||
bi_end(&s->rep->buf) < b_ptr(&s->rep->buf, txn->rsp.next) ||
bi_end(&s->rep->buf) > s->rep->buf.data + s->rep->buf.size - global.tune.maxrewrite)) {
if (s->rep->buf.o) {
* later, so the session will never terminate. We
* must terminate it now.
*/
- if (unlikely(req->flags & BF_FULL)) {
+ if (unlikely(buffer_full(&req->buf, global.tune.maxrewrite))) {
/* FIXME: check if URI is set and return Status
* 414 Request URI too long instead.
*/
missing_data:
/* we get here if we need to wait for more data */
- if (req->flags & BF_FULL) {
+ if (buffer_full(&req->buf, global.tune.maxrewrite)) {
session_inc_http_err_ctr(s);
goto return_bad_req;
}
}
/* we get here if we need to wait for more data */
- if (!(req->flags & (BF_FULL | BF_READ_ERROR | BF_SHUTR))) {
+ if (!(req->flags & (BF_SHUTR | BF_READ_ERROR)) && !buffer_full(&req->buf, global.tune.maxrewrite)) {
/* Not enough data. We'll re-use the http-request
* timeout here. Ideally, we should set the timeout
* relative to the accept() date. We just set the
*/
if (s->req->buf.i) {
if (s->rep->buf.o &&
- !(s->rep->flags & BF_FULL) &&
+ !buffer_full(&s->rep->buf, global.tune.maxrewrite) &&
bi_end(&s->rep->buf) <= s->rep->buf.data + s->rep->buf.size - global.tune.maxrewrite)
s->rep->flags |= BF_EXPECT_MORE;
}
* data later, which is much more complicated.
*/
if (buffer_not_empty(&rep->buf) && msg->msg_state < HTTP_MSG_ERROR) {
- if (unlikely((rep->flags & BF_FULL) ||
+ if (unlikely(channel_full(rep) ||
bi_end(&rep->buf) < b_ptr(&rep->buf, msg->next) ||
bi_end(&rep->buf) > rep->buf.data + rep->buf.size - global.tune.maxrewrite)) {
if (rep->buf.o) {
}
/* too large response does not fit in buffer. */
- else if (rep->flags & BF_FULL) {
+ else if (buffer_full(&rep->buf, global.tune.maxrewrite)) {
if (msg->err_pos < 0)
msg->err_pos = rep->buf.i;
goto hdr_response_bad;
return 0;
if (unlikely(txn->req.msg_state < HTTP_MSG_BODY)) {
- if ((msg->msg_state == HTTP_MSG_ERROR) || (s->req->flags & BF_FULL)) {
+ if ((msg->msg_state == HTTP_MSG_ERROR) ||
+ buffer_full(&s->req->buf, global.tune.maxrewrite)) {
smp->data.uint = 0;
return -1;
}
/* Still no valid request ? */
if (unlikely(msg->msg_state < HTTP_MSG_BODY)) {
- if ((msg->msg_state == HTTP_MSG_ERROR) || (s->req->flags & BF_FULL)) {
+ if ((msg->msg_state == HTTP_MSG_ERROR) ||
+ buffer_full(&s->req->buf, global.tune.maxrewrite)) {
smp->data.uint = 0;
return -1;
}
channel_is_empty(si->ob))
si_shutw(si);
- if ((si->ob->flags & (BF_FULL|BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == 0)
+ if ((si->ob->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == 0 && !channel_full(si->ob))
si->flags |= SI_FL_WAIT_DATA;
/* we're almost sure that we need some space if the buffer is not
/* save flags to detect changes */
old_flags = si->flags;
- if (likely((si->ob->flags & (BF_SHUTW|BF_WRITE_PARTIAL|BF_FULL|BF_DONT_READ)) == BF_WRITE_PARTIAL &&
+ if (likely((si->ob->flags & (BF_SHUTW|BF_WRITE_PARTIAL|BF_DONT_READ)) == BF_WRITE_PARTIAL &&
+ !channel_full(si->ob) &&
(si->ob->prod->flags & SI_FL_WAIT_ROOM)))
si_chk_rcv(si->ob->prod);
(si->ib->cons->flags & SI_FL_WAIT_DATA)) {
si_chk_snd(si->ib->cons);
/* check if the consumer has freed some space */
- if (!(si->ib->flags & BF_FULL))
+ if (!channel_full(si->ib))
si->flags &= ~SI_FL_WAIT_ROOM;
}
__FUNCTION__,
si, si->state, si->ib->flags, si->ob->flags);
- if (unlikely(si->state != SI_ST_EST || (ib->flags & BF_SHUTR)))
+ if (unlikely(si->state != SI_ST_EST || (ib->flags & (BF_SHUTR|BF_HIJACK|BF_DONT_READ))))
return;
- if (ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) {
+ if (channel_full(ib)) {
/* stop reading */
- if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL)
- si->flags |= SI_FL_WAIT_ROOM;
+ si->flags |= SI_FL_WAIT_ROOM;
}
else {
/* (re)start reading */
si->ob->wex = TICK_ETERNITY;
}
- if ((si->ob->flags & (BF_FULL|BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == 0)
+ if ((si->ob->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == 0 && !channel_full(si->ob))
si->flags |= SI_FL_WAIT_DATA;
if (si->ob->flags & BF_WRITE_ACTIVITY) {
if (tick_isset(si->ib->rex))
si->ib->rex = tick_add_ifset(now_ms, si->ib->rto);
- if (likely((si->ob->flags & (BF_SHUTW|BF_WRITE_PARTIAL|BF_FULL|BF_DONT_READ)) == BF_WRITE_PARTIAL &&
+ if (likely((si->ob->flags & (BF_SHUTW|BF_WRITE_PARTIAL|BF_DONT_READ)) == BF_WRITE_PARTIAL &&
+ !channel_full(si->ob) &&
(si->ob->prod->flags & SI_FL_WAIT_ROOM)))
si_chk_rcv(si->ob->prod);
}
/* check if the consumer has freed some space either in the
* buffer or in the pipe.
*/
- if (!(si->ib->flags & BF_FULL) &&
+ if (!channel_full(si->ib) &&
(!last_len || !si->ib->pipe || si->ib->pipe->data < last_len))
si->flags &= ~SI_FL_WAIT_ROOM;
}
__conn_data_stop_recv(conn);
si->ib->rex = TICK_ETERNITY;
}
- else if ((si->ib->flags & (BF_SHUTR|BF_READ_PARTIAL|BF_FULL|BF_DONT_READ|BF_READ_NOEXP)) == BF_READ_PARTIAL) {
+ else if ((si->ib->flags & (BF_SHUTR|BF_READ_PARTIAL|BF_DONT_READ|BF_READ_NOEXP)) == BF_READ_PARTIAL &&
+ !channel_full(si->ib)) {
if (tick_isset(si->ib->rex))
si->ib->rex = tick_add_ifset(now_ms, si->ib->rto);
}
/* Check if we need to close the read side */
if (!(ib->flags & BF_SHUTR)) {
/* Read not closed, update FD status and timeout for reads */
- if (ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) {
+ if ((ib->flags & (BF_HIJACK|BF_DONT_READ)) || channel_full(ib)) {
/* stop reading */
if (!(si->flags & SI_FL_WAIT_ROOM)) {
- if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL)
+ if (!(ib->flags & (BF_HIJACK|BF_DONT_READ))) /* full */
si->flags |= SI_FL_WAIT_ROOM;
conn_data_stop_recv(&si->conn);
ib->rex = TICK_ETERNITY;
if (channel_is_empty(ob)) {
/* stop writing */
if (!(si->flags & SI_FL_WAIT_DATA)) {
- if ((ob->flags & (BF_FULL|BF_HIJACK|BF_SHUTW_NOW)) == 0)
+ if ((ob->flags & (BF_HIJACK|BF_SHUTW_NOW)) == 0)
si->flags |= SI_FL_WAIT_DATA;
conn_data_stop_send(&si->conn);
ob->wex = TICK_ETERNITY;
return;
}
- if (ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) {
+ if ((ib->flags & (BF_HIJACK|BF_DONT_READ)) || channel_full(ib)) {
/* stop reading */
- if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL)
+ if (!(ib->flags & (BF_HIJACK|BF_DONT_READ))) /* full */
si->flags |= SI_FL_WAIT_ROOM;
conn_data_stop_recv(&si->conn);
}
goto out_wakeup;
}
- if ((ob->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_FULL|BF_HIJACK)) == 0)
+ if ((ob->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == 0)
si->flags |= SI_FL_WAIT_DATA;
ob->wex = TICK_ETERNITY;
}