CLEANUP: channel: remove any reference of the hijackers

Hijackers were functions designed to inject data into channels in the
distant past. They became unused around 1.3.16, and since there has
not been any user of this mechanism to date, it's uncertain whether
the mechanism still works (and it's not really useful anymore). So
better remove it as well as the pointer it uses in the channel struct.
This commit is contained in:
Willy Tarreau 2012-11-11 23:05:39 +01:00
parent 50fc7777c6
commit b31c971bef
4 changed files with 28 additions and 66 deletions

View File

@ -190,26 +190,6 @@ static inline void channel_abort(struct channel *chn)
chn->flags &= ~CF_AUTO_CONNECT;
}
/* Installs <func> as a hijacker on the channel <b> for session <s>. The hijack
* flag is set, and the function called once. The function is responsible for
* clearing the hijack bit. It is possible that the function clears the flag
* during this first call.
*/
static inline void channel_install_hijacker(struct session *s,
struct channel *chn,
void (*func)(struct session *, struct channel *))
{
chn->hijacker = func;
chn->flags |= CF_HIJACK;
func(s, chn);
}
/* Releases the channel from hijacking mode. Often used by the hijack function */
static inline void channel_stop_hijacker(struct channel *chn)
{
chn->flags &= ~CF_HIJACK;
}
/* allow the consumer to try to establish a new connection. */
static inline void channel_auto_connect(struct channel *chn)
{

View File

@ -45,7 +45,7 @@
* CF_SHUTR, CF_SHUTW
*
* - persistent control flags managed only by application level :
* CF_SHUT*_NOW, CF_*_ENA, CF_HIJACK
* CF_SHUT*_NOW, CF_*_ENA
*
* The flags have been arranged for readability, so that the read and write
* bits have the same position in a byte (read being the lower byte and write
@ -75,10 +75,10 @@
#define CF_SHUTW_NOW 0x00004000 /* the consumer must shut down for writes ASAP */
#define CF_AUTO_CLOSE 0x00008000 /* producer can forward shutdown to other side */
/* When either CF_SHUTR_NOW or CF_HIJACK is set, it is strictly forbidden for
* the producer to alter the buffer contents. When CF_SHUTW_NOW is set, the
* consumer is free to perform a shutw() when it has consumed the last contents,
* otherwise the session processor will do it anyway.
/* When CF_SHUTR_NOW is set, it is strictly forbidden for the producer to alter
* the buffer contents. When CF_SHUTW_NOW is set, the consumer is free to perform
* a shutw() when it has consumed the last contents, otherwise the session processor
* will do it anyway.
*
* The SHUT* flags work like this :
*
@ -95,9 +95,8 @@
* 1 1 impossible
*
* The SHUTW_NOW flag should be set by the session processor when SHUTR and AUTO_CLOSE
* are both set. It may also be set by a hijacker at the end of data. And it may also
* be set by the producer when it detects SHUTR while directly forwarding data to the
* consumer.
* are both set. And it may also be set by the producer when it detects SHUTR while
* directly forwarding data to the consumer.
*
* The SHUTR_NOW flag is mostly used to force the producer to abort when an error is
* detected on the consumer side.
@ -106,7 +105,7 @@
#define CF_STREAMER 0x00010000 /* the producer is identified as streaming data */
#define CF_STREAMER_FAST 0x00020000 /* the consumer seems to eat the stream very fast */
#define CF_HIJACK 0x00040000 /* the producer is temporarily replaced by ->hijacker */
/* unused: 0x00040000 */
#define CF_ANA_TIMEOUT 0x00080000 /* the analyser timeout has expired */
#define CF_READ_ATTACHED 0x00100000 /* the read side is attached for the first time */
#define CF_KERN_SPLICING 0x00200000 /* kernel splicing desired for this channel */
@ -185,7 +184,6 @@ struct channel {
int wex; /* expiration date for a write or connect, in ticks */
int rto; /* read timeout, in ticks */
int wto; /* write timeout, in ticks */
void (*hijacker)(struct session *, struct channel *); /* alternative content producer */
int analyse_exp; /* expiration date for current analysers (if set) */
};

View File

@ -1883,23 +1883,7 @@ struct task *process_session(struct task *t)
resync_response:
/* Analyse response */
if (unlikely(s->rep->flags & CF_HIJACK)) {
/* In inject mode, we wake up everytime something has
* happened on the write side of the buffer.
*/
unsigned int flags = s->rep->flags;
if ((s->rep->flags & (CF_WRITE_PARTIAL|CF_WRITE_ERROR|CF_SHUTW)) &&
!channel_full(s->rep)) {
s->rep->hijacker(s, s->rep);
}
if ((s->rep->flags ^ flags) & CF_MASK_STATIC) {
rpf_last = s->rep->flags;
goto resync_response;
}
}
else if (((s->rep->flags & ~rpf_last) & CF_MASK_ANALYSER) ||
if (((s->rep->flags & ~rpf_last) & CF_MASK_ANALYSER) ||
(s->rep->flags ^ rpf_last) & CF_MASK_STATIC ||
s->si[0].state != rp_cons_last ||
s->si[1].state != rp_prod_last) {
@ -2086,10 +2070,10 @@ struct task *process_session(struct task *t)
* recent call to channel_abort().
*/
if (!s->req->analysers &&
!(s->req->flags & (CF_HIJACK|CF_SHUTW|CF_SHUTR_NOW)) &&
!(s->req->flags & (CF_SHUTW|CF_SHUTR_NOW)) &&
(s->req->prod->state >= SI_ST_EST) &&
(s->req->to_forward != CHN_INFINITE_FORWARD)) {
/* This buffer is freewheeling, there's no analyser nor hijacker
/* This buffer is freewheeling, there's no analyser
* attached to it. If any data are left in, we'll permit them to
* move.
*/
@ -2129,7 +2113,7 @@ struct task *process_session(struct task *t)
* happen either because the input is closed or because we want to force a close
* once the server has begun to respond.
*/
if (unlikely((s->req->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_HIJACK|CF_AUTO_CLOSE|CF_SHUTR)) ==
if (unlikely((s->req->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CLOSE|CF_SHUTR)) ==
(CF_AUTO_CLOSE|CF_SHUTR)))
channel_shutw_now(s->req);
@ -2223,10 +2207,10 @@ struct task *process_session(struct task *t)
* recent call to channel_abort().
*/
if (!s->rep->analysers &&
!(s->rep->flags & (CF_HIJACK|CF_SHUTW|CF_SHUTR_NOW)) &&
!(s->rep->flags & (CF_SHUTW|CF_SHUTR_NOW)) &&
(s->rep->prod->state >= SI_ST_EST) &&
(s->rep->to_forward != CHN_INFINITE_FORWARD)) {
/* This buffer is freewheeling, there's no analyser nor hijacker
/* This buffer is freewheeling, there's no analyser
* attached to it. If any data are left in, we'll permit them to
* move.
*/
@ -2276,7 +2260,7 @@ struct task *process_session(struct task *t)
*/
/* first, let's check if the response buffer needs to shutdown(write) */
if (unlikely((s->rep->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_HIJACK|CF_AUTO_CLOSE|CF_SHUTR)) ==
if (unlikely((s->rep->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CLOSE|CF_SHUTR)) ==
(CF_AUTO_CLOSE|CF_SHUTR)))
channel_shutw_now(s->rep);

View File

@ -149,11 +149,11 @@ static void stream_int_update_embedded(struct stream_interface *si)
if (si->state != SI_ST_EST)
return;
if ((si->ob->flags & (CF_SHUTW|CF_HIJACK|CF_SHUTW_NOW)) == CF_SHUTW_NOW &&
if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW &&
channel_is_empty(si->ob))
si_shutw(si);
if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_HIJACK)) == 0 && !channel_full(si->ob))
if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == 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
@ -370,7 +370,7 @@ static void stream_int_chk_rcv(struct stream_interface *si)
__FUNCTION__,
si, si->state, si->ib->flags, si->ob->flags);
if (unlikely(si->state != SI_ST_EST || (ib->flags & (CF_SHUTR|CF_HIJACK|CF_DONT_READ))))
if (unlikely(si->state != SI_ST_EST || (ib->flags & (CF_SHUTR|CF_DONT_READ))))
return;
if (channel_full(ib)) {
@ -581,14 +581,14 @@ static int si_conn_wake_cb(struct connection *conn)
/* process consumer side */
if (channel_is_empty(si->ob)) {
if (((si->ob->flags & (CF_SHUTW|CF_HIJACK|CF_SHUTW_NOW)) == CF_SHUTW_NOW) &&
if (((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW) &&
(si->state == SI_ST_EST))
stream_int_shutw(si);
__conn_data_stop_send(conn);
si->ob->wex = TICK_ETERNITY;
}
if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_HIJACK)) == 0 && !channel_full(si->ob))
if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == 0 && !channel_full(si->ob))
si->flags |= SI_FL_WAIT_DATA;
if (si->ob->flags & CF_WRITE_ACTIVITY) {
@ -712,7 +712,7 @@ static int si_conn_send_loop(struct connection *conn)
if ((!(chn->flags & (CF_NEVER_WAIT|CF_SEND_DONTWAIT)) &&
((chn->to_forward && chn->to_forward != CHN_INFINITE_FORWARD) ||
(chn->flags & CF_EXPECT_MORE))) ||
((chn->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_HIJACK)) == CF_SHUTW_NOW))
((chn->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW))
send_flag |= MSG_MORE;
ret = conn->xprt->snd_buf(conn, chn->buf, send_flag);
@ -755,10 +755,10 @@ void stream_int_update_conn(struct stream_interface *si)
/* Check if we need to close the read side */
if (!(ib->flags & CF_SHUTR)) {
/* Read not closed, update FD status and timeout for reads */
if ((ib->flags & (CF_HIJACK|CF_DONT_READ)) || channel_full(ib)) {
if ((ib->flags & CF_DONT_READ) || channel_full(ib)) {
/* stop reading */
if (!(si->flags & SI_FL_WAIT_ROOM)) {
if (!(ib->flags & (CF_HIJACK|CF_DONT_READ))) /* full */
if (!(ib->flags & CF_DONT_READ)) /* full */
si->flags |= SI_FL_WAIT_ROOM;
conn_data_stop_recv(si->conn);
ib->rex = TICK_ETERNITY;
@ -783,7 +783,7 @@ void stream_int_update_conn(struct stream_interface *si)
if (channel_is_empty(ob)) {
/* stop writing */
if (!(si->flags & SI_FL_WAIT_DATA)) {
if ((ob->flags & (CF_HIJACK|CF_SHUTW_NOW)) == 0)
if ((ob->flags & CF_SHUTW_NOW) == 0)
si->flags |= SI_FL_WAIT_DATA;
conn_data_stop_send(si->conn);
ob->wex = TICK_ETERNITY;
@ -826,9 +826,9 @@ static void stream_int_chk_rcv_conn(struct stream_interface *si)
if (unlikely(si->state > SI_ST_EST || (ib->flags & CF_SHUTR)))
return;
if ((ib->flags & (CF_HIJACK|CF_DONT_READ)) || channel_full(ib)) {
if ((ib->flags & CF_DONT_READ) || channel_full(ib)) {
/* stop reading */
if (!(ib->flags & (CF_HIJACK|CF_DONT_READ))) /* full */
if (!(ib->flags & CF_DONT_READ)) /* full */
si->flags |= SI_FL_WAIT_ROOM;
conn_data_stop_recv(si->conn);
}
@ -880,14 +880,14 @@ static void stream_int_chk_snd_conn(struct stream_interface *si)
* ->o limit was reached. Maybe we just wrote the last
* chunk and need to close.
*/
if (((ob->flags & (CF_SHUTW|CF_HIJACK|CF_AUTO_CLOSE|CF_SHUTW_NOW)) ==
if (((ob->flags & (CF_SHUTW|CF_AUTO_CLOSE|CF_SHUTW_NOW)) ==
(CF_AUTO_CLOSE|CF_SHUTW_NOW)) &&
(si->state == SI_ST_EST)) {
si_shutw(si);
goto out_wakeup;
}
if ((ob->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_HIJACK)) == 0)
if ((ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == 0)
si->flags |= SI_FL_WAIT_DATA;
ob->wex = TICK_ETERNITY;
}