]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stream_interface: remove the external task type target
authorWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2012 22:14:16 +0000 (23:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2012 22:14:16 +0000 (23:14 +0100)
Before connections were introduced, it was possible to connect an
external task to a stream interface. However it was left as an
exercise for the brave implementer to find how that ought to be
done.

The feature was broken since the introduction of connections and
was never fixed since due to lack of users. Better remove this dead
code now.

include/proto/connection.h
include/proto/stream_interface.h
include/types/connection.h
src/stream_interface.c

index 0236d95e495db79a86014baef63b217e8848285f..b0596a845522b1fdab02ecc2244b18fc1b90f49d 100644 (file)
@@ -405,12 +405,6 @@ static inline void set_target_applet(struct target *dest, struct si_applet *a)
        dest->ptr.a = a;
 }
 
-static inline void set_target_task(struct target *dest, struct task *t)
-{
-       dest->type = TARG_TYPE_TASK;
-       dest->ptr.t = t;
-}
-
 static inline struct target *copy_target(struct target *dest, struct target *src)
 {
        *dest = *src;
index 9cc39f53ff5e9cc5d042eeca83ca78dbce06f3d2..7c9595a1f209573c4a042e10f2b4f523893653d2 100644 (file)
@@ -41,14 +41,11 @@ int stream_int_shutw(struct stream_interface *si);
 void stream_sock_read0(struct stream_interface *si);
 
 extern struct si_ops si_embedded_ops;
-extern struct si_ops si_task_ops;
 extern struct si_ops si_conn_ops;
 extern struct data_cb si_conn_cb;
 
 struct task *stream_int_register_handler(struct stream_interface *si,
                                         struct si_applet *app);
-struct task *stream_int_register_handler_task(struct stream_interface *si,
-                                             struct task *(*fct)(struct task *));
 void stream_int_unregister_handler(struct stream_interface *si);
 
 static inline const struct protocol *si_ctrl(struct stream_interface *si)
@@ -74,12 +71,6 @@ static inline void si_prepare_embedded(struct stream_interface *si)
        conn_prepare(si->conn, NULL, NULL, NULL, si);
 }
 
-static inline void si_prepare_task(struct stream_interface *si)
-{
-       si->ops = &si_task_ops;
-       conn_prepare(si->conn, NULL, NULL, NULL, si);
-}
-
 /* Sends a shutr to the connection using the data layer */
 static inline void si_shutr(struct stream_interface *si)
 {
index b828ffaccfbcaa63b53d17980325826ebdb79cf7..57e9fea5aa245d4b2dc255755b4cebe7bdc2d5bf 100644 (file)
@@ -148,7 +148,6 @@ enum {
        TARG_TYPE_PROXY,            /* target is a proxy   ; use address with the proxy's settings */
        TARG_TYPE_SERVER,           /* target is a server  ; use address with server's and its proxy's settings */
        TARG_TYPE_APPLET,           /* target is an applet ; use only the applet */
-       TARG_TYPE_TASK,             /* target is a task running an external applet */
 };
 
 
@@ -193,7 +192,6 @@ struct target {
                struct proxy *p;      /* when type is TARG_TYPE_PROXY  */
                struct server *s;     /* when type is TARG_TYPE_SERVER */
                struct si_applet *a;  /* when type is TARG_TYPE_APPLET */
-               struct task *t;       /* when type is TARG_TYPE_TASK */
                struct listener *l;   /* when type is TARG_TYPE_CLIENT */
        } ptr;
 } __attribute__((packed));
index 1834b627bbde3556d76c1f03fcc7fd88206a72a4..bcedcb095a3378180969c016850fd1392099eea5 100644 (file)
@@ -36,7 +36,6 @@
 #include <types/pipe.h>
 
 /* socket functions used when running a stream interface as a task */
-static void stream_int_update(struct stream_interface *si);
 static void stream_int_update_embedded(struct stream_interface *si);
 static void stream_int_chk_rcv(struct stream_interface *si);
 static void stream_int_chk_snd(struct stream_interface *si);
@@ -54,13 +53,6 @@ struct si_ops si_embedded_ops = {
        .chk_snd = stream_int_chk_snd,
 };
 
-/* stream-interface operations for external tasks */
-struct si_ops si_task_ops = {
-       .update  = stream_int_update,
-       .chk_rcv = stream_int_chk_rcv,
-       .chk_snd = stream_int_chk_snd,
-};
-
 /* stream-interface operations for connections */
 struct si_ops si_conn_ops = {
        .update  = stream_int_update_conn,
@@ -126,17 +118,6 @@ void stream_int_retnclose(struct stream_interface *si, const struct chunk *msg)
        channel_shutr_now(si->ob);
 }
 
-/* default update function for scheduled tasks, not used for embedded tasks */
-static void stream_int_update(struct stream_interface *si)
-{
-       DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n",
-               __FUNCTION__,
-               si, si->state, si->ib->flags, si->ob->flags);
-
-       if (!(si->flags & SI_FL_DONT_WAKE) && si->owner)
-               task_wakeup(si->owner, TASK_WOKEN_IO);
-}
-
 /* default update function for embedded tasks, to be used at the end of the i/o handler */
 static void stream_int_update_embedded(struct stream_interface *si)
 {
@@ -426,56 +407,17 @@ struct task *stream_int_register_handler(struct stream_interface *si, struct si_
 
        si_prepare_embedded(si);
        set_target_applet(&si->conn->target, app);
-       si->release   = app->release;
+       si->release = app->release;
        si->flags |= SI_FL_WAIT_DATA;
        return si->owner;
 }
 
-/* Register a function to handle a stream_interface as a standalone task. The
- * new task itself is returned and is assigned as si->owner. The stream_interface
- * pointer will be pointed to by the task's context. The handler can be detached
- * by using stream_int_unregister_handler().
- * FIXME: the code should be updated to ensure that we don't change si->owner
- * anymore as this is not needed. However, process_session still relies on it.
- */
-struct task *stream_int_register_handler_task(struct stream_interface *si,
-                                             struct task *(*fct)(struct task *))
-{
-       struct task *t;
-
-       DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", fct, si, si->owner);
-
-       si_prepare_task(si);
-       clear_target(&si->conn->target);
-       si->release   = NULL;
-       si->flags |= SI_FL_WAIT_DATA;
-
-       t = task_new();
-       si->owner = t;
-       if (!t)
-               return t;
-
-       set_target_task(&si->conn->target, t);
-
-       t->process = fct;
-       t->context = si;
-       task_wakeup(si->owner, TASK_WOKEN_INIT);
-
-       return t;
-}
-
 /* Unregister a stream interface handler. This must be called by the handler task
- * itself when it detects that it is in the SI_ST_DIS state. This function can
- * both detach standalone handlers and embedded handlers.
+ * itself when it detects that it is in the SI_ST_DIS state.
  */
 void stream_int_unregister_handler(struct stream_interface *si)
 {
-       if (si->conn->target.type == TARG_TYPE_TASK) {
-               /* external handler : kill the task */
-               task_delete(si->conn->target.ptr.t);
-               task_free(si->conn->target.ptr.t);
-       }
-       si->release   = NULL;
+       si->release = NULL;
        si->owner = NULL;
        clear_target(&si->conn->target);
 }