MINOR: channel: rename bi_erase() to channel_truncate()

It applies to the channel and it doesn't erase outgoing data, only
pending unread data, which is strictly equivalent to what recv()
does with MSG_TRUNC, so that new name is more accurate and intuitive.
This commit is contained in:
Willy Tarreau 2015-01-14 20:32:59 +01:00
parent b5051f8742
commit 319f745ba0
3 changed files with 14 additions and 15 deletions

View File

@ -334,12 +334,11 @@ static inline int channel_recv_max(const struct channel *chn)
return ret; return ret;
} }
/* Cut the "tail" of the channel's buffer, which means strip it to the length /* Truncate any unread data in the channel's buffer, and disable forwarding.
* of unsent data only, and kill any remaining unsent data. Any scheduled * Outgoing data are left intact. This is mainly to be used to send error
* forwarding is stopped. This is mainly to be used to send error messages * messages after existing data.
* after existing data.
*/ */
static inline void bi_erase(struct channel *chn) static inline void channel_truncate(struct channel *chn)
{ {
if (!chn->buf->o) if (!chn->buf->o)
return channel_erase(chn); return channel_erase(chn);

View File

@ -5233,7 +5233,7 @@ int http_sync_res_state(struct session *s)
if (txn->rsp.msg_state == HTTP_MSG_CLOSED) { if (txn->rsp.msg_state == HTTP_MSG_CLOSED) {
http_msg_closed: http_msg_closed:
/* drop any pending data */ /* drop any pending data */
bi_erase(chn); channel_truncate(chn);
channel_auto_close(chn); channel_auto_close(chn);
channel_auto_read(chn); channel_auto_read(chn);
goto wait_other_side; goto wait_other_side;
@ -5300,7 +5300,7 @@ int http_resync_states(struct session *s)
channel_abort(s->req); channel_abort(s->req);
channel_auto_close(s->req); channel_auto_close(s->req);
channel_auto_read(s->req); channel_auto_read(s->req);
bi_erase(s->req); channel_truncate(s->req);
} }
else if ((txn->req.msg_state == HTTP_MSG_DONE || else if ((txn->req.msg_state == HTTP_MSG_DONE ||
txn->req.msg_state == HTTP_MSG_CLOSED) && txn->req.msg_state == HTTP_MSG_CLOSED) &&
@ -5745,7 +5745,7 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
rep->analysers = 0; rep->analysers = 0;
txn->status = 502; txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER; rep->prod->flags |= SI_FL_NOLINGER;
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502)); stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK)) if (!(s->flags & SN_ERR_MASK))
@ -5780,7 +5780,7 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
rep->analysers = 0; rep->analysers = 0;
txn->status = 502; txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER; rep->prod->flags |= SI_FL_NOLINGER;
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502)); stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK)) if (!(s->flags & SN_ERR_MASK))
@ -5807,7 +5807,7 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
rep->analysers = 0; rep->analysers = 0;
txn->status = 504; txn->status = 504;
rep->prod->flags |= SI_FL_NOLINGER; rep->prod->flags |= SI_FL_NOLINGER;
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_504)); stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_504));
if (!(s->flags & SN_ERR_MASK)) if (!(s->flags & SN_ERR_MASK))
@ -5828,7 +5828,7 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
channel_auto_close(rep); channel_auto_close(rep);
txn->status = 400; txn->status = 400;
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_400)); stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_400));
if (!(s->flags & SN_ERR_MASK)) if (!(s->flags & SN_ERR_MASK))
@ -5857,7 +5857,7 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
rep->analysers = 0; rep->analysers = 0;
txn->status = 502; txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER; rep->prod->flags |= SI_FL_NOLINGER;
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502)); stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK)) if (!(s->flags & SN_ERR_MASK))
@ -6189,7 +6189,7 @@ skip_content_length:
s->logs.logwait = 0; s->logs.logwait = 0;
s->logs.level = 0; s->logs.level = 0;
s->rep->flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */ s->rep->flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, NULL); stream_int_retnclose(rep->cons, NULL);
return 0; return 0;
} }
@ -6260,7 +6260,7 @@ int http_process_res_common(struct session *s, struct channel *rep, int an_bit,
txn->status = 502; txn->status = 502;
s->logs.t_data = -1; /* was not a valid response */ s->logs.t_data = -1; /* was not a valid response */
rep->prod->flags |= SI_FL_NOLINGER; rep->prod->flags |= SI_FL_NOLINGER;
bi_erase(rep); channel_truncate(rep);
stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502)); stream_int_retnclose(rep->cons, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK)) if (!(s->flags & SN_ERR_MASK))
s->flags |= SN_ERR_PRXCOND; s->flags |= SN_ERR_PRXCOND;

View File

@ -125,8 +125,8 @@ void stream_int_retnclose(struct stream_interface *si, const struct chunk *msg)
channel_abort(si->ib); channel_abort(si->ib);
channel_auto_close(si->ib); channel_auto_close(si->ib);
channel_erase(si->ib); channel_erase(si->ib);
channel_truncate(si->ob);
bi_erase(si->ob);
if (likely(msg && msg->len)) if (likely(msg && msg->len))
bo_inject(si->ob, msg->str, msg->len); bo_inject(si->ob, msg->str, msg->len);