]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: use si_task() to retrieve the task from the stream int
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Nov 2014 11:08:47 +0000 (12:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Mar 2015 19:41:46 +0000 (20:41 +0100)
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.

include/proto/stream_interface.h
src/session.c
src/stream_interface.c

index 4d5abcf2af5dea26391865f6780e4955337ef498..584abcf6d5de117905566eb1e2d3f2d0b3dcc72e 100644 (file)
@@ -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.
index f271e41261e4fd793e736781d1ff4af2131c5022..7f726d42934ab395c725d2e07f5d84f04f981362 100644 (file)
@@ -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.
index 8ccf78e6005a168f3f2a71931392e484de39f429..bfc67c24c0a7c78194915e9ceac848e58fa48b29 100644 (file)
@@ -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 */