mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-13 15:04:42 +00:00
MEDIUM: stream-int: use si_task() to retrieve the task from the stream int
We go back to the session to get the owner. Here again it's very easy and is just a matter of relative offsets. Since the owner always exists and always points to the session's task, we can remove some unneeded tests.
This commit is contained in:
parent
aefd79004c
commit
07373b8660
@ -73,6 +73,15 @@ static inline struct session *si_sess(struct stream_interface *si)
|
||||
return LIST_ELEM(si, struct session *, si[0]);
|
||||
}
|
||||
|
||||
/* returns the task associated to this stream interface */
|
||||
static inline struct task *si_task(struct stream_interface *si)
|
||||
{
|
||||
if (si->flags & SI_FL_ISBACK)
|
||||
return LIST_ELEM(si, struct session *, si[1])->task;
|
||||
else
|
||||
return LIST_ELEM(si, struct session *, si[0])->task;
|
||||
}
|
||||
|
||||
/* Initializes all required fields for a new appctx. Note that it does the
|
||||
* minimum acceptable initialization for an appctx. This means only the
|
||||
* 3 integer states st0, st1, st2 are zeroed.
|
||||
|
@ -1750,10 +1750,8 @@ struct task *process_session(struct task *t)
|
||||
rpf_last = s->res.flags & ~CF_MASK_ANALYSER;
|
||||
|
||||
/* we don't want the stream interface functions to recursively wake us up */
|
||||
if (s->req.prod->owner == t)
|
||||
s->req.prod->flags |= SI_FL_DONT_WAKE;
|
||||
if (s->req.cons->owner == t)
|
||||
s->req.cons->flags |= SI_FL_DONT_WAKE;
|
||||
s->req.prod->flags |= SI_FL_DONT_WAKE;
|
||||
s->req.cons->flags |= SI_FL_DONT_WAKE;
|
||||
|
||||
/* 1a: Check for low level timeouts if needed. We just set a flag on
|
||||
* stream interfaces when their timeouts have expired.
|
||||
|
@ -212,8 +212,8 @@ static void stream_int_update_embedded(struct stream_interface *si)
|
||||
((si_oc(si)->flags & CF_WAKE_WRITE) &&
|
||||
(si_oc(si)->prod->state != SI_ST_EST ||
|
||||
(channel_is_empty(si_oc(si)) && !si_oc(si)->to_forward)))))) {
|
||||
if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
if (!(si->flags & SI_FL_DONT_WAKE))
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
if (si_ic(si)->flags & CF_READ_ACTIVITY)
|
||||
si_ic(si)->flags &= ~CF_READ_DONTWAIT;
|
||||
@ -250,8 +250,8 @@ static void stream_int_shutr(struct stream_interface *si)
|
||||
}
|
||||
|
||||
/* note that if the task exists, it must unregister itself once it runs */
|
||||
if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
if (!(si->flags & SI_FL_DONT_WAKE))
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,8 +299,8 @@ static void stream_int_shutw(struct stream_interface *si)
|
||||
}
|
||||
|
||||
/* note that if the task exists, it must unregister itself once it runs */
|
||||
if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
if (!(si->flags & SI_FL_DONT_WAKE))
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
|
||||
/* default chk_rcv function for scheduled tasks */
|
||||
@ -322,8 +322,8 @@ static void stream_int_chk_rcv(struct stream_interface *si)
|
||||
else {
|
||||
/* (re)start reading */
|
||||
si->flags &= ~SI_FL_WAIT_ROOM;
|
||||
if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
if (!(si->flags & SI_FL_DONT_WAKE))
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,8 +350,8 @@ static void stream_int_chk_snd(struct stream_interface *si)
|
||||
if (!tick_isset(ob->wex))
|
||||
ob->wex = tick_add_ifset(now_ms, ob->wto);
|
||||
|
||||
if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
if (!(si->flags & SI_FL_DONT_WAKE))
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
|
||||
/* Register an applet to handle a stream_interface as part of the
|
||||
@ -366,7 +366,7 @@ struct appctx *stream_int_register_handler(struct stream_interface *si, struct s
|
||||
{
|
||||
struct appctx *appctx;
|
||||
|
||||
DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner);
|
||||
DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si_task(si));
|
||||
|
||||
appctx = si_alloc_appctx(si);
|
||||
if (!appctx)
|
||||
@ -639,7 +639,7 @@ static int si_conn_wake_cb(struct connection *conn)
|
||||
((si_oc(si)->flags & CF_WAKE_WRITE) &&
|
||||
(si_oc(si)->prod->state != SI_ST_EST ||
|
||||
(channel_is_empty(si_oc(si)) && !si_oc(si)->to_forward)))))) {
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
if (si_ic(si)->flags & CF_READ_ACTIVITY)
|
||||
si_ic(si)->flags &= ~CF_READ_DONTWAIT;
|
||||
@ -1058,8 +1058,8 @@ static void stream_int_chk_snd_conn(struct stream_interface *si)
|
||||
((channel_is_empty(si_oc(si)) && !ob->to_forward) ||
|
||||
si->state != SI_ST_EST)))) {
|
||||
out_wakeup:
|
||||
if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
|
||||
task_wakeup(si->owner, TASK_WOKEN_IO);
|
||||
if (!(si->flags & SI_FL_DONT_WAKE))
|
||||
task_wakeup(si_task(si), TASK_WOKEN_IO);
|
||||
}
|
||||
|
||||
/* commit possible polling changes */
|
||||
|
Loading…
Reference in New Issue
Block a user