]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: connection: replace struct target with a pointer to an enum
authorWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2012 23:42:33 +0000 (00:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2012 23:42:33 +0000 (00:42 +0100)
Instead of storing a couple of (int, ptr) in the struct connection
and the struct session, we use a different method : we only store a
pointer to an integer which is stored inside the target object and
which contains a unique type identifier. That way, the pointer allows
us to retrieve the object type (by dereferencing it) and the object's
address (by computing the displacement in the target structure). The
NULL pointer always corresponds to OBJ_TYPE_NONE.

This reduces the size of the connection and session structs. It also
simplifies target assignment and compare.

In order to improve the generated code, we try to put the obj_type
element at the beginning of all the structs (listener, server, proxy,
si_applet), so that the original and target pointers are always equal.

A lot of code was touched by massive replaces, but the changes are not
that important.

22 files changed:
include/proto/connection.h
include/proto/obj_type.h [new file with mode: 0644]
include/types/connection.h
include/types/listener.h
include/types/obj_type.h [new file with mode: 0644]
include/types/proxy.h
include/types/server.h
include/types/session.h
include/types/stream_interface.h
src/backend.c
src/cfgparse.c
src/checks.c
src/dumpstats.c
src/log.c
src/peers.c
src/proto_http.c
src/proto_tcp.c
src/proxy.c
src/queue.c
src/session.c
src/ssl_sock.c
src/stream_interface.c

index b0596a845522b1fdab02ecc2244b18fc1b90f49d..4686e7f115f37769f2611a4b8076a8e956eaa16b 100644 (file)
@@ -26,6 +26,7 @@
 #include <common/memory.h>
 #include <types/connection.h>
 #include <types/listener.h>
+#include <proto/obj_type.h>
 
 extern struct pool_head *pool2_connection;
 
@@ -375,61 +376,6 @@ static inline int conn_sock_shutw_pending(struct connection *c)
        return (c->flags & (CO_FL_DATA_WR_SH | CO_FL_SOCK_WR_SH)) == CO_FL_DATA_WR_SH;
 }
 
-static inline void clear_target(struct target *dest)
-{
-       dest->type = TARG_TYPE_NONE;
-       dest->ptr.v = NULL;
-}
-
-static inline void set_target_client(struct target *dest, struct listener *l)
-{
-       dest->type = TARG_TYPE_CLIENT;
-       dest->ptr.l = l;
-}
-
-static inline void set_target_server(struct target *dest, struct server *s)
-{
-       dest->type = TARG_TYPE_SERVER;
-       dest->ptr.s = s;
-}
-
-static inline void set_target_proxy(struct target *dest, struct proxy *p)
-{
-       dest->type = TARG_TYPE_PROXY;
-       dest->ptr.p = p;
-}
-
-static inline void set_target_applet(struct target *dest, struct si_applet *a)
-{
-       dest->type = TARG_TYPE_APPLET;
-       dest->ptr.a = a;
-}
-
-static inline struct target *copy_target(struct target *dest, struct target *src)
-{
-       *dest = *src;
-       return dest;
-}
-
-static inline int target_match(struct target *a, struct target *b)
-{
-       return a->type == b->type && a->ptr.v == b->ptr.v;
-}
-
-static inline struct server *target_srv(struct target *t)
-{
-       if (!t || t->type != TARG_TYPE_SERVER)
-               return NULL;
-       return t->ptr.s;
-}
-
-static inline struct listener *target_client(struct target *t)
-{
-       if (!t || t->type != TARG_TYPE_CLIENT)
-               return NULL;
-       return t->ptr.l;
-}
-
 /* Retrieves the connection's source address */
 static inline void conn_get_from_addr(struct connection *conn)
 {
@@ -440,8 +386,8 @@ static inline void conn_get_from_addr(struct connection *conn)
                return;
 
        if (conn->ctrl->get_src(conn->t.sock.fd, (struct sockaddr *)&conn->addr.from,
-                                sizeof(conn->addr.from),
-                                conn->target.type != TARG_TYPE_CLIENT) == -1)
+                               sizeof(conn->addr.from),
+                               obj_type(conn->target) != OBJ_TYPE_LISTENER) == -1)
                return;
        conn->flags |= CO_FL_ADDR_FROM_SET;
 }
@@ -456,8 +402,8 @@ static inline void conn_get_to_addr(struct connection *conn)
                return;
 
        if (conn->ctrl->get_dst(conn->t.sock.fd, (struct sockaddr *)&conn->addr.to,
-                                sizeof(conn->addr.to),
-                                conn->target.type != TARG_TYPE_CLIENT) == -1)
+                               sizeof(conn->addr.to),
+                               obj_type(conn->target) != OBJ_TYPE_LISTENER) == -1)
                return;
        conn->flags |= CO_FL_ADDR_TO_SET;
 }
diff --git a/include/proto/obj_type.h b/include/proto/obj_type.h
new file mode 100644 (file)
index 0000000..44c2f83
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * include/proto/obj_type.h
+ * This file contains function prototypes to manipulate object types
+ *
+ * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _PROTO_OBJ_TYPE_H
+#define _PROTO_OBJ_TYPE_H
+
+#include <common/config.h>
+#include <common/memory.h>
+#include <types/listener.h>
+#include <types/obj_type.h>
+#include <types/proxy.h>
+#include <types/server.h>
+#include <types/stream_interface.h>
+
+static inline enum obj_type obj_type(enum obj_type *t)
+{
+       if (!t || *t > OBJ_TYPE_APPLET)
+               return OBJ_TYPE_NONE;
+       return *t;
+}
+
+static inline struct listener *objt_listener(enum obj_type *t)
+{
+       if (!t || *t != OBJ_TYPE_LISTENER)
+               return NULL;
+       return container_of(t, struct listener, obj_type);
+}
+
+static inline struct proxy *objt_proxy(enum obj_type *t)
+{
+       if (!t || *t != OBJ_TYPE_PROXY)
+               return NULL;
+       return container_of(t, struct proxy, obj_type);
+}
+
+static inline struct server *objt_server(enum obj_type *t)
+{
+       if (!t || *t != OBJ_TYPE_SERVER)
+               return NULL;
+       return container_of(t, struct server, obj_type);
+}
+
+static inline struct si_applet *objt_applet(enum obj_type *t)
+{
+       if (!t || *t != OBJ_TYPE_APPLET)
+               return NULL;
+       return container_of(t, struct si_applet, obj_type);
+}
+
+#endif /* _PROTO_OBJ_TYPE_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index 57e9fea5aa245d4b2dc255755b4cebe7bdc2d5bf..6149dd598a5cf3e0528d797ae5c7cda88f7a4489 100644 (file)
@@ -28,6 +28,7 @@
 #include <common/config.h>
 
 #include <types/listener.h>
+#include <types/obj_type.h>
 #include <types/protocol.h>
 
 /* referenced below */
@@ -141,16 +142,6 @@ enum {
        CO_FL_XPRT_TRACKED  = 0x80000000,
 };
 
-/* target types */
-enum {
-       TARG_TYPE_NONE = 0,         /* no target set, pointer is NULL by definition */
-       TARG_TYPE_CLIENT,           /* target is a client, pointer is NULL by definition */
-       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 */
-};
-
-
 /* xprt_ops describes transport-layer operations for a connection. They
  * generally run over a socket-based control layer, but not always. Some
  * of them are used for data transfer with the upper layer (rcv_*, snd_*)
@@ -184,18 +175,6 @@ struct data_cb {
        int  (*init)(struct connection *conn);  /* data-layer initialization */
 };
 
-/* a target describes what is on the remote side of the connection. */
-struct target {
-       int type;
-       union {
-               void *v;              /* pointer value, for any type */
-               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 listener *l;   /* when type is TARG_TYPE_CLIENT */
-       } ptr;
-} __attribute__((packed));
-
 /* This structure describes a connection with its methods and data.
  * A connection may be performed to proxy or server via a local or remote
  * socket, and can also be made to an internal applet. It can support
@@ -216,7 +195,7 @@ struct connection {
                        int fd;       /* file descriptor for a stream driver when known */
                } sock;
        } t;
-       struct target target;         /* the target to connect to (server, proxy, applet, ...) */
+       enum obj_type *target;        /* the target to connect to (server, proxy, applet, ...) */
        struct {
                struct sockaddr_storage from;   /* client address, or address to spoof when connecting to the server */
                struct sockaddr_storage to;     /* address reached by the client, or address to connect to */
index 918ba0ac7606b36211dc4b21b4a1537269476dfc..323c996c54e959502c4c3ee25b61fa27242f33ba 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <common/config.h>
 #include <common/mini-clist.h>
+#include <types/obj_type.h>
 #include <eb32tree.h>
 
 /* Some pointer types reference below */
@@ -146,6 +147,7 @@ struct bind_conf {
  * the fdtab.
  */
 struct listener {
+       enum obj_type obj_type;         /* object type = OBJ_TYPE_LISTENER */
        int fd;                         /* the listen socket */
        char *name;                     /* */
        int luid;                       /* listener universally unique ID, used for SNMP */
diff --git a/include/types/obj_type.h b/include/types/obj_type.h
new file mode 100644 (file)
index 0000000..cfb3e34
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * include/types/obj_type.h
+ * This file declares some object types for use in various structures.
+ *
+ * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _TYPES_OBJ_TYPE_H
+#define _TYPES_OBJ_TYPE_H
+
+/* The principle is to be able to change the type of a pointer by pointing
+ * it directly to an object type. The object type indicates the format of the
+ * structure holing the type, and this is used to retrieve the pointer to the
+ * beginning of the structure. Doing so saves us from having to maintain both
+ * a pointer and a type for elements such as connections which can point to
+ * various types of objects.
+ */
+
+/* object types */
+enum obj_type {
+       OBJ_TYPE_NONE = 0,     /* pointer is NULL by definition */
+       OBJ_TYPE_LISTENER,     /* object is a struct listener */
+       OBJ_TYPE_PROXY,        /* object is a struct proxy */
+       OBJ_TYPE_SERVER,       /* object is a struct server */
+       OBJ_TYPE_APPLET,       /* object is a struct si_applet */
+};
+
+#endif /* _TYPES_OBJ_TYPE_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index 343d4ad049ba34d6d4d2b6d4f425cc12988c6eb2..5d99423abc11dcc13b5daa24e0bcacdcb904f4c3 100644 (file)
@@ -42,6 +42,7 @@
 #include <types/freq_ctr.h>
 #include <types/listener.h>
 #include <types/log.h>
+#include <types/obj_type.h>
 #include <types/proto_http.h>
 #include <types/sample.h>
 #include <types/session.h>
@@ -200,10 +201,11 @@ struct error_snapshot {
 };
 
 struct proxy {
-       struct in_addr mon_net, mon_mask;       /* don't forward connections from this net (network order) FIXME: should support IPv6 */
+       enum obj_type obj_type;                 /* object type == OBJ_TYPE_PROXY */
        int state;                              /* proxy state */
        int options;                            /* PR_O_REDISP, PR_O_TRANSP, ... */
        int options2;                           /* PR_O2_* */
+       struct in_addr mon_net, mon_mask;       /* don't forward connections from this net (network order) FIXME: should support IPv6 */
        unsigned int ck_opts;                   /* PR_CK_* (cookie options) */
        unsigned int fe_req_ana, be_req_ana;    /* bitmap of common request protocol analysers for the frontend and backend */
        unsigned int fe_rsp_ana, be_rsp_ana;    /* bitmap of common response protocol analysers for the frontend and backend */
index e65c2c021a6fc3a783941b03a1f1e7da7ae89c0d..4806ffa17398035ea618965684455cc7a253cc6b 100644 (file)
@@ -36,6 +36,7 @@
 #include <types/connection.h>
 #include <types/counters.h>
 #include <types/freq_ctr.h>
+#include <types/obj_type.h>
 #include <types/port_range.h>
 #include <types/proxy.h>
 #include <types/queue.h>
@@ -107,6 +108,7 @@ struct tree_occ {
 };
 
 struct server {
+       enum obj_type obj_type;                 /* object type == OBJ_TYPE_SERVER */
        struct server *next;
        int state;                              /* server state (SRV_*) */
        int prev_state;                         /* server state before last change (SRV_*) */
index ae11f81790c5ec94a0d0ec568cc4e9a8656359d6..f0a5be645b591763de0c473d2be494ff6d237f15 100644 (file)
@@ -34,6 +34,7 @@
 #include <types/channel.h>
 #include <types/compression.h>
 
+#include <types/obj_type.h>
 #include <types/proto_http.h>
 #include <types/proxy.h>
 #include <types/queue.h>
  *    immediately assigned when SN_DIRECT is determined. Both must be cleared
  *    when clearing SN_DIRECT (eg: redispatch).
  *  - ->srv has no meaning without SN_ASSIGNED and must not be checked without
- *    it. ->target and ->target_type may be used to check previous ->srv after
- *    a failed connection attempt.
+ *    it. ->target may be used to check previous ->srv after a failed connection attempt.
  *  - a session being processed has srv_conn set.
  *  - srv_conn might remain after SN_DIRECT has been reset, but the assigned
  *    server should eventually be released.
  */
 struct session {
        int flags;                              /* some flags describing the session */
-       struct target target;                   /* target to use for this session */
+       enum obj_type *target;                  /* target to use for this session */
 
        struct channel *req;                    /* request buffer */
        struct channel *rep;                    /* response buffer */
index 04c0dca1b7e710c0c89c2e4a527c227db3233bf5..a8084913982cb258b6375a16ed7a6d1a164dbc28 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <types/channel.h>
 #include <types/connection.h>
+#include <types/obj_type.h>
 #include <common/config.h>
 
 /* A stream interface must have its own errors independently of the buffer's,
@@ -160,8 +161,9 @@ struct stream_interface {
 
 /* An applet designed to run in a stream interface */
 struct si_applet {
-       char *name; /* applet's name to report in logs */
-       void (*fct)(struct stream_interface *);  /* internal I/O handler, may never be NULL */
+       enum obj_type obj_type;                      /* object type = OBJ_TYPE_APPLET */
+       char *name;                                  /* applet's name to report in logs */
+       void (*fct)(struct stream_interface *);      /* internal I/O handler, may never be NULL */
        void (*release)(struct stream_interface *);  /* callback to release resources, may be NULL */
 };
 
index 82a88beb21b8ed68b74566b0d52557485c83ff2d..f4b90ced35a55d94f48d6518bdf01a4aa8e4fa8d 100644 (file)
@@ -38,6 +38,7 @@
 #include <proto/lb_fwlc.h>
 #include <proto/lb_fwrr.h>
 #include <proto/lb_map.h>
+#include <proto/obj_type.h>
 #include <proto/protocol.h>
 #include <proto/proto_http.h>
 #include <proto/proto_tcp.h>
@@ -489,7 +490,7 @@ int assign_server(struct session *s)
        if (unlikely(s->pend_pos || s->flags & SN_ASSIGNED))
                goto out_err;
 
-       prev_srv  = target_srv(&s->target);
+       prev_srv  = objt_server(s->target);
        conn_slot = s->srv_conn;
 
        /* We have to release any connection slot before applying any LB algo,
@@ -498,13 +499,13 @@ int assign_server(struct session *s)
        if (conn_slot)
                sess_change_server(s, NULL);
 
-       /* We will now try to find the good server and store it into <target_srv(&s->target)>.
-        * Note that <target_srv(&s->target)> may be NULL in case of dispatch or proxy mode,
+       /* We will now try to find the good server and store it into <objt_server(s->target)>.
+        * Note that <objt_server(s->target)> may be NULL in case of dispatch or proxy mode,
         * as well as if no server is available (check error code).
         */
 
        srv = NULL;
-       clear_target(&s->target);
+       s->target = NULL;
 
        if (s->be->lbprm.algo & BE_LB_KIND) {
                /* we must check if we have at least one server available */
@@ -631,15 +632,15 @@ int assign_server(struct session *s)
                        s->be->be_counters.cum_lbconn++;
                        srv->counters.cum_lbconn++;
                }
-               set_target_server(&s->target, srv);
+               s->target = &srv->obj_type;
        }
        else if (s->be->options & (PR_O_DISPATCH | PR_O_TRANSP)) {
-               set_target_proxy(&s->target, s->be);
+               s->target = &s->be->obj_type;
        }
        else if ((s->be->options & PR_O_HTTP_PROXY) &&
                 is_addr(&s->req->cons->conn->addr.to)) {
                /* in proxy mode, we need a valid destination address */
-               set_target_proxy(&s->target, s->be);
+               s->target = &s->be->obj_type;
        }
        else {
                err = SRV_STATUS_NOSRV;
@@ -691,7 +692,7 @@ int assign_server_address(struct session *s)
                if (!(s->flags & SN_ASSIGNED))
                        return SRV_STATUS_INTERNAL;
 
-               s->req->cons->conn->addr.to = target_srv(&s->target)->addr;
+               s->req->cons->conn->addr.to = objt_server(s->target)->addr;
 
                if (!is_addr(&s->req->cons->conn->addr.to)) {
                        /* if the server has no address, we use the same address
@@ -710,7 +711,7 @@ int assign_server_address(struct session *s)
 
                /* if this server remaps proxied ports, we'll use
                 * the port the client connected to with an offset. */
-               if (target_srv(&s->target)->state & SRV_MAPPORTS) {
+               if (objt_server(s->target)->state & SRV_MAPPORTS) {
                        int base_port;
 
                        if (!(s->be->options & PR_O_TRANSP))
@@ -764,7 +765,7 @@ int assign_server_address(struct session *s)
  * Returns :
  *
  *   SRV_STATUS_OK       if everything is OK.
- *   SRV_STATUS_NOSRV    if no server is available. target_srv(&s->target) = NULL.
+ *   SRV_STATUS_NOSRV    if no server is available. objt_server(s->target) = NULL.
  *   SRV_STATUS_QUEUED   if the connection has been queued.
  *   SRV_STATUS_FULL     if the server(s) is/are saturated and the
  *                       connection could not be queued at the server's,
@@ -783,7 +784,7 @@ int assign_server_and_queue(struct session *s)
 
        err = SRV_STATUS_OK;
        if (!(s->flags & SN_ASSIGNED)) {
-               struct server *prev_srv = target_srv(&s->target);
+               struct server *prev_srv = objt_server(s->target);
 
                err = assign_server(s);
                if (prev_srv) {
@@ -796,7 +797,7 @@ int assign_server_and_queue(struct session *s)
                         *  - if the server remained the same : update retries.
                         */
 
-                       if (prev_srv != target_srv(&s->target)) {
+                       if (prev_srv != objt_server(s->target)) {
                                if ((s->txn.flags & TX_CK_MASK) == TX_CK_VALID) {
                                        s->txn.flags &= ~TX_CK_MASK;
                                        s->txn.flags |= TX_CK_DOWN;
@@ -814,7 +815,7 @@ int assign_server_and_queue(struct session *s)
        switch (err) {
        case SRV_STATUS_OK:
                /* we have SN_ASSIGNED set */
-               srv = target_srv(&s->target);
+               srv = objt_server(s->target);
                if (!srv)
                        return SRV_STATUS_OK;   /* dispatch or proxy mode */
 
@@ -882,7 +883,7 @@ int assign_server_and_queue(struct session *s)
 static void assign_tproxy_address(struct session *s)
 {
 #if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY)
-       struct server *srv = target_srv(&s->target);
+       struct server *srv = objt_server(s->target);
 
        if (srv && srv->state & SRV_BIND_SRC) {
                switch (srv->state & SRV_TPROXY_MASK) {
@@ -981,13 +982,13 @@ int connect_server(struct session *s)
        }
 
        /* the target was only on the session, assign it to the SI now */
-       copy_target(&s->req->cons->conn->target, &s->target);
+       s->req->cons->conn->target = s->target;
 
        /* set the correct protocol on the output stream interface */
-       if (s->target.type == TARG_TYPE_SERVER) {
-               si_prepare_conn(s->req->cons, target_srv(&s->target)->proto, target_srv(&s->target)->xprt);
+       if (objt_server(s->target)) {
+               si_prepare_conn(s->req->cons, objt_server(s->target)->proto, objt_server(s->target)->xprt);
        }
-       else if (s->target.type == TARG_TYPE_PROXY) {
+       else if (obj_type(s->target) == OBJ_TYPE_PROXY) {
                /* proxies exclusively run on raw_sock right now */
                si_prepare_conn(s->req->cons, protocol_by_family(s->req->cons->conn->addr.to.ss_family), &raw_sock);
                if (!si_ctrl(s->req->cons))
@@ -998,7 +999,7 @@ int connect_server(struct session *s)
 
        /* process the case where the server requires the PROXY protocol to be sent */
        s->req->cons->send_proxy_ofs = 0;
-       if (s->target.type == TARG_TYPE_SERVER && (s->target.ptr.s->state & SRV_SEND_PROXY)) {
+       if (objt_server(s->target) && (objt_server(s->target)->state & SRV_SEND_PROXY)) {
                s->req->cons->send_proxy_ofs = 1; /* must compute size */
                conn_get_to_addr(s->req->prod->conn);
        }
@@ -1021,7 +1022,7 @@ int connect_server(struct session *s)
        /* set connect timeout */
        s->req->cons->exp = tick_add_ifset(now_ms, s->be->timeout.connect);
 
-       srv = target_srv(&s->target);
+       srv = objt_server(s->target);
        if (srv) {
                s->flags |= SN_CURR_SESS;
                srv->cur_sess++;
@@ -1053,7 +1054,7 @@ int srv_redispatch_connect(struct session *t)
         */
  redispatch:
        conn_err = assign_server_and_queue(t);
-       srv = target_srv(&t->target);
+       srv = objt_server(t->target);
 
        switch (conn_err) {
        case SRV_STATUS_OK:
@@ -1173,13 +1174,13 @@ int tcp_persist_rdp_cookie(struct session *s, struct channel *req, int an_bit)
        if (*p != '.')
                goto no_cookie;
 
-       clear_target(&s->target);
+       s->target = NULL;
        while (srv) {
                if (memcmp(&addr, &(srv->addr), sizeof(addr)) == 0) {
                        if ((srv->state & SRV_RUNNING) || (px->options & PR_O_PERSIST)) {
                                /* we found the server and it is usable */
                                s->flags |= SN_DIRECT | SN_ASSIGNED;
-                               set_target_server(&s->target, srv);
+                               s->target = &srv->obj_type;
                                break;
                        }
                }
@@ -1488,11 +1489,11 @@ static int
 acl_fetch_srv_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
                  const struct arg *args, struct sample *smp)
 {
-       if (!target_srv(&l4->target))
+       if (!objt_server(l4->target))
                return 0;
 
        smp->type = SMP_T_UINT;
-       smp->data.uint = target_srv(&l4->target)->puid;
+       smp->data.uint = objt_server(l4->target)->puid;
 
        return 1;
 }
index 6c58e43a0ba032ea42cea9efb5394b4c8e2b3da8..d3b630051fb822e887fd4daacc6cd542c08818e7 100644 (file)
@@ -35,6 +35,7 @@
 #include <types/capture.h>
 #include <types/compression.h>
 #include <types/global.h>
+#include <types/obj_type.h>
 #include <types/peers.h>
 
 #include <proto/acl.h>
@@ -265,6 +266,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
 
                for (; port <= end; port++) {
                        l = (struct listener *)calloc(1, sizeof(struct listener));
+                       l->obj_type = OBJ_TYPE_LISTENER;
                        LIST_ADDQ(&curproxy->conf.listeners, &l->by_fe);
                        LIST_ADDQ(&bind_conf->listeners, &l->by_bind);
                        l->frontend = curproxy;
@@ -4034,6 +4036,7 @@ stats_error_parsing:
                        newsrv->conf.file = strdup(file);
                        newsrv->conf.line = linenum;
 
+                       newsrv->obj_type = OBJ_TYPE_SERVER;
                        LIST_INIT(&newsrv->actconns);
                        LIST_INIT(&newsrv->pendconns);
                        do_check = 0;
index e3c8620c851ce4422c060015e7a34935ff5e04cd..f13273ed44ba7bb56a32b1ac2db5e07be0ae6475 100644 (file)
@@ -349,7 +349,7 @@ static int check_for_pending(struct server *s)
                p = pendconn_from_px(s->proxy);
                if (!p)
                        break;
-               set_target_server(&p->sess->target, s);
+               p->sess->target = &s->obj_type;
                sess = p->sess;
                pendconn_free(p);
                task_wakeup(sess->task, TASK_WOKEN_RES);
@@ -1299,7 +1299,7 @@ static struct task *process_chk(struct task *t)
                }
 
                /* prepare a new connection */
-               set_target_server(&conn->target, s);
+               conn->target = &s->obj_type;
                conn_prepare(conn, &check_conn_cb, s->check.proto, s->check.xprt, s);
 
                /* no client address */
index 306fc61dbd7644017a88dce6d12db510e7418a5b..5f59ddec00873de3914ca68e975522574ecd6fa9 100644 (file)
@@ -125,7 +125,7 @@ static int stats_accept(struct session *s)
 {
        /* we have a dedicated I/O handler for the stats */
        stream_int_register_handler(&s->si[1], &cli_applet);
-       copy_target(&s->target, &s->si[1].conn->target); // for logging only
+       s->target = s->si[1].conn->target; // for logging only
        s->si[1].conn->xprt_ctx = s;
        s->si[1].applet.st1 = 0;
        s->si[1].applet.st0 = STAT_CLI_INIT;
@@ -3419,8 +3419,8 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si)
                if (sess->be->cap & PR_CAP_BE)
                        chunk_appendf(&trash,
                                     "  server=%s (id=%u)",
-                                    target_srv(&sess->target) ? target_srv(&sess->target)->id : "<none>",
-                                    target_srv(&sess->target) ? target_srv(&sess->target)->puid : 0);
+                                    objt_server(sess->target) ? objt_server(sess->target)->id : "<none>",
+                                    objt_server(sess->target) ? objt_server(sess->target)->puid : 0);
                else
                        chunk_appendf(&trash, "  server=<NONE> (id=-1)");
 
@@ -3638,7 +3638,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
                                             get_host_port(&curr_sess->si[0].conn->addr.from),
                                             curr_sess->fe->id,
                                             (curr_sess->be->cap & PR_CAP_BE) ? curr_sess->be->id : "<NONE>",
-                                            target_srv(&curr_sess->target) ? target_srv(&curr_sess->target)->id : "<none>"
+                                            objt_server(curr_sess->target) ? objt_server(curr_sess->target)->id : "<none>"
                                             );
                                break;
                        case AF_UNIX:
@@ -3647,7 +3647,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
                                             curr_sess->listener->luid,
                                             curr_sess->fe->id,
                                             (curr_sess->be->cap & PR_CAP_BE) ? curr_sess->be->id : "<NONE>",
-                                            target_srv(&curr_sess->target) ? target_srv(&curr_sess->target)->id : "<none>"
+                                            objt_server(curr_sess->target) ? objt_server(curr_sess->target)->id : "<none>"
                                             );
                                break;
                        }
@@ -4161,12 +4161,14 @@ static int bind_parse_level(char **args, int cur_arg, struct proxy *px, struct b
 }
 
 struct si_applet http_stats_applet = {
+       .obj_type = OBJ_TYPE_APPLET,
        .name = "<STATS>", /* used for logging */
        .fct = http_stats_io_handler,
        .release = NULL,
 };
 
 static struct si_applet cli_applet = {
+       .obj_type = OBJ_TYPE_APPLET,
        .name = "<CLI>", /* used for logging */
        .fct = cli_io_handler,
        .release = NULL,
index 79158e07b6cd402e56ebf626f6f436aca8ba27a5..06a2a57ac17b61344d0832776908118ad31e43e1 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -800,12 +800,12 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis
 
        if (!(tolog & LW_SVID))
                svid = "-";
-       else switch (s->target.type) {
-       case TARG_TYPE_SERVER:
-               svid = s->target.ptr.s->id;
+       else switch (obj_type(s->target)) {
+       case OBJ_TYPE_SERVER:
+               svid = objt_server(s->target)->id;
                break;
-       case TARG_TYPE_APPLET:
-               svid = s->target.ptr.a->name;
+       case OBJ_TYPE_APPLET:
+               svid = objt_applet(s->target)->name;
                break;
        default:
                svid = "<NOSRV>";
@@ -1175,8 +1175,8 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis
                                break;
 
                        case LOG_FMT_SRVCONN:  // %sc
-                               ret = ultoa_o(target_srv(&s->target) ?
-                                                target_srv(&s->target)->cur_sess :
+                               ret = ultoa_o(obj_type(s->target) ?
+                                                objt_server(s->target)->cur_sess :
                                                 0, tmplog, dst + maxsize - tmplog);
                                if (ret == NULL)
                                        goto out;
index 263cc8a0df112e45e040db3e6754b75ce706deda..6870f8f86f98019bb19baa54cb9af1392eff9915 100644 (file)
@@ -25,7 +25,8 @@
 #include <common/time.h>
 
 #include <types/global.h>
-#include <proto/listener.h>
+#include <types/listener.h>
+#include <types/obj_type.h>
 #include <types/peers.h>
 
 #include <proto/acl.h>
@@ -1040,6 +1041,7 @@ quit:
 }
 
 static struct si_applet peer_applet = {
+       .obj_type = OBJ_TYPE_APPLET,
        .name = "<PEER>", /* used for logging */
        .fct = peer_io_handler,
        .release = peer_session_release,
@@ -1052,8 +1054,7 @@ static void peer_session_forceshutdown(struct session * session)
 {
        struct stream_interface *oldsi;
 
-       if (session->si[0].conn->target.type == TARG_TYPE_APPLET &&
-           session->si[0].conn->target.ptr.a == &peer_applet) {
+       if (objt_applet(session->si[0].conn->target) == &peer_applet) {
                oldsi = &session->si[0];
        }
        else {
@@ -1077,7 +1078,7 @@ int peer_accept(struct session *s)
 {
         /* we have a dedicated I/O handler for the stats */
        stream_int_register_handler(&s->si[1], &peer_applet);
-       copy_target(&s->target, &s->si[1].conn->target); // for logging only
+       s->target = s->si[1].conn->target; // for logging only
        s->si[1].conn->xprt_ctx = s;
        s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
 
@@ -1161,7 +1162,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[0].err_loc = NULL;
        s->si[0].release = NULL;
        s->si[0].send_proxy_ofs = 0;
-       set_target_client(&s->si[0].conn->target, l);
+       s->si[0].conn->target = &l->obj_type;
        s->si[0].exp = TICK_ETERNITY;
        s->si[0].flags = SI_FL_NONE;
        if (s->fe->options2 & PR_O2_INDEPSTR)
@@ -1180,7 +1181,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[1].err_loc = NULL;
        s->si[1].release = NULL;
        s->si[1].send_proxy_ofs = 0;
-       set_target_proxy(&s->si[1].conn->target, s->be);
+       s->si[1].conn->target = &s->be->obj_type;
        si_prepare_conn(&s->si[1], peer->proto, peer->xprt);
        s->si[1].exp = TICK_ETERNITY;
        s->si[1].flags = SI_FL_NONE;
@@ -1188,7 +1189,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
                s->si[1].flags |= SI_FL_INDEP_STR;
 
        session_init_srv_conn(s);
-       set_target_proxy(&s->target, s->be);
+       s->target = &s->be->obj_type;
        s->pend_pos = NULL;
 
        /* init store persistence */
index c1fd6a74fbae3b34f64d3049add7ffc3aaa8438c..f86dcc35709c710d2ad8c657a924674aedae6c95 100644 (file)
@@ -767,7 +767,7 @@ void perform_http_redirect(struct session *s, struct stream_interface *si)
        trash.len = strlen(HTTP_302);
        memcpy(trash.str, HTTP_302, trash.len);
 
-       srv = target_srv(&s->target);
+       srv = objt_server(s->target);
 
        /* 2: add the server's prefix */
        if (trash.len + srv->rdr_len > trash.size)
@@ -3202,7 +3202,7 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit,
                s->logs.tv_request = now;
                s->task->nice = -32; /* small boost for HTTP statistics */
                stream_int_register_handler(s->rep->prod, &http_stats_applet);
-               copy_target(&s->target, &s->rep->prod->conn->target); // for logging only
+               s->target = s->rep->prod->conn->target; // for logging only
                s->rep->prod->conn->xprt_ctx = s;
                s->rep->prod->applet.st0 = s->rep->prod->applet.st1 = 0;
                req->analysers = 0;
@@ -4056,16 +4056,16 @@ void http_end_txn_clean_session(struct session *s)
        if (s->pend_pos)
                pendconn_free(s->pend_pos);
 
-       if (target_srv(&s->target)) {
+       if (objt_server(s->target)) {
                if (s->flags & SN_CURR_SESS) {
                        s->flags &= ~SN_CURR_SESS;
-                       target_srv(&s->target)->cur_sess--;
+                       objt_server(s->target)->cur_sess--;
                }
-               if (may_dequeue_tasks(target_srv(&s->target), s->be))
-                       process_srv_queue(target_srv(&s->target));
+               if (may_dequeue_tasks(objt_server(s->target), s->be))
+                       process_srv_queue(objt_server(s->target));
        }
 
-       clear_target(&s->target);
+       s->target = NULL;
 
        s->req->cons->state     = s->req->cons->prev_state = SI_ST_INI;
        s->req->cons->conn->t.sock.fd = -1; /* just to help with debugging */
@@ -4349,8 +4349,8 @@ int http_sync_res_state(struct session *s)
                else if (chn->flags & CF_SHUTW) {
                        txn->rsp.msg_state = HTTP_MSG_ERROR;
                        s->be->be_counters.cli_aborts++;
-                       if (target_srv(&s->target))
-                               target_srv(&s->target)->counters.cli_aborts++;
+                       if (objt_server(s->target))
+                               objt_server(s->target)->counters.cli_aborts++;
                        goto wait_other_side;
                }
        }
@@ -4628,8 +4628,8 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit
 
                s->fe->fe_counters.cli_aborts++;
                s->be->be_counters.cli_aborts++;
-               if (target_srv(&s->target))
-                       target_srv(&s->target)->counters.cli_aborts++;
+               if (objt_server(s->target))
+                       objt_server(s->target)->counters.cli_aborts++;
 
                goto return_bad_req_stats_ok;
        }
@@ -4698,8 +4698,8 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit
 
        s->fe->fe_counters.srv_aborts++;
        s->be->be_counters.srv_aborts++;
-       if (target_srv(&s->target))
-               target_srv(&s->target)->counters.srv_aborts++;
+       if (objt_server(s->target))
+               objt_server(s->target)->counters.srv_aborts++;
 
        if (!(s->flags & SN_ERR_MASK))
                s->flags |= SN_ERR_SRVCL;
@@ -4823,9 +4823,9 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
                                http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
 
                        s->be->be_counters.failed_resp++;
-                       if (target_srv(&s->target)) {
-                               target_srv(&s->target)->counters.failed_resp++;
-                               health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_HDRRSP);
+                       if (objt_server(s->target)) {
+                               objt_server(s->target)->counters.failed_resp++;
+                               health_adjust(objt_server(s->target), HANA_STATUS_HTTP_HDRRSP);
                        }
                abort_response:
                        channel_auto_close(rep);
@@ -4856,9 +4856,9 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
                                http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
 
                        s->be->be_counters.failed_resp++;
-                       if (target_srv(&s->target)) {
-                               target_srv(&s->target)->counters.failed_resp++;
-                               health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_READ_ERROR);
+                       if (objt_server(s->target)) {
+                               objt_server(s->target)->counters.failed_resp++;
+                               health_adjust(objt_server(s->target), HANA_STATUS_HTTP_READ_ERROR);
                        }
 
                        channel_auto_close(rep);
@@ -4881,9 +4881,9 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
                                http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
 
                        s->be->be_counters.failed_resp++;
-                       if (target_srv(&s->target)) {
-                               target_srv(&s->target)->counters.failed_resp++;
-                               health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_READ_TIMEOUT);
+                       if (objt_server(s->target)) {
+                               objt_server(s->target)->counters.failed_resp++;
+                               health_adjust(objt_server(s->target), HANA_STATUS_HTTP_READ_TIMEOUT);
                        }
 
                        channel_auto_close(rep);
@@ -4906,9 +4906,9 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
                                http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
 
                        s->be->be_counters.failed_resp++;
-                       if (target_srv(&s->target)) {
-                               target_srv(&s->target)->counters.failed_resp++;
-                               health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_BROKEN_PIPE);
+                       if (objt_server(s->target)) {
+                               objt_server(s->target)->counters.failed_resp++;
+                               health_adjust(objt_server(s->target), HANA_STATUS_HTTP_BROKEN_PIPE);
                        }
 
                        channel_auto_close(rep);
@@ -4969,8 +4969,8 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
        if (n == 4)
                session_inc_http_err_ctr(s);
 
-       if (target_srv(&s->target))
-               target_srv(&s->target)->counters.p.http.rsp[n]++;
+       if (objt_server(s->target))
+               objt_server(s->target)->counters.p.http.rsp[n]++;
 
        /* check if the response is HTTP/1.1 or above */
        if ((msg->sl.st.v_l == 8) &&
@@ -4990,11 +4990,11 @@ int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
         * and 505 are triggered on demand by client request, so we must not
         * count them as server failures.
         */
-       if (target_srv(&s->target)) {
+       if (objt_server(s->target)) {
                if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505))
-                       health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_OK);
+                       health_adjust(objt_server(s->target), HANA_STATUS_HTTP_OK);
                else
-                       health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_STS);
+                       health_adjust(objt_server(s->target), HANA_STATUS_HTTP_STS);
        }
 
        /*
@@ -5258,9 +5258,9 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
                        if (rule_set->rsp_exp != NULL) {
                                if (apply_filters_to_response(t, rep, rule_set) < 0) {
                                return_bad_resp:
-                                       if (target_srv(&t->target)) {
-                                               target_srv(&t->target)->counters.failed_resp++;
-                                               health_adjust(target_srv(&t->target), HANA_STATUS_HTTP_RSP);
+                                       if (objt_server(t->target)) {
+                                               objt_server(t->target)->counters.failed_resp++;
+                                               health_adjust(objt_server(t->target), HANA_STATUS_HTTP_RSP);
                                        }
                                        t->be->be_counters.failed_resp++;
                                return_srv_prx_502:
@@ -5279,8 +5279,8 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
 
                        /* has the response been denied ? */
                        if (txn->flags & TX_SVDENY) {
-                               if (target_srv(&t->target))
-                                       target_srv(&t->target)->counters.failed_secu++;
+                               if (objt_server(t->target))
+                                       objt_server(t->target)->counters.failed_secu++;
 
                                t->be->be_counters.denied_resp++;
                                t->fe->fe_counters.denied_resp++;
@@ -5348,7 +5348,7 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
                /*
                 * 6: add server cookie in the response if needed
                 */
-               if (target_srv(&t->target) && (t->be->ck_opts & PR_CK_INS) &&
+               if (objt_server(t->target) && (t->be->ck_opts & PR_CK_INS) &&
                    !((txn->flags & TX_SCK_FOUND) && (t->be->ck_opts & PR_CK_PSV)) &&
                    (!(t->flags & SN_DIRECT) ||
                     ((t->be->cookie_maxidle || txn->cookie_last_date) &&
@@ -5363,13 +5363,13 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
                         * requests and this one isn't. Note that servers which don't have cookies
                         * (eg: some backup servers) will return a full cookie removal request.
                         */
-                       if (!target_srv(&t->target)->cookie) {
+                       if (!objt_server(t->target)->cookie) {
                                chunk_printf(&trash,
                                              "Set-Cookie: %s=; Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/",
                                              t->be->cookie_name);
                        }
                        else {
-                               chunk_printf(&trash, "Set-Cookie: %s=%s", t->be->cookie_name, target_srv(&t->target)->cookie);
+                               chunk_printf(&trash, "Set-Cookie: %s=%s", t->be->cookie_name, objt_server(t->target)->cookie);
 
                                if (t->be->cookie_maxidle || t->be->cookie_maxlife) {
                                        /* emit last_date, which is mandatory */
@@ -5404,7 +5404,7 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
                                goto return_bad_resp;
 
                        txn->flags &= ~TX_SCK_MASK;
-                       if (target_srv(&t->target)->cookie && (t->flags & SN_DIRECT))
+                       if (objt_server(t->target)->cookie && (t->flags & SN_DIRECT))
                                /* the server did not change, only the date was updated */
                                txn->flags |= TX_SCK_UPDATED;
                        else
@@ -5438,8 +5438,8 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
                         * a set-cookie header. We'll block it as requested by
                         * the 'checkcache' option, and send an alert.
                         */
-                       if (target_srv(&t->target))
-                               target_srv(&t->target)->counters.failed_secu++;
+                       if (objt_server(t->target))
+                               objt_server(t->target)->counters.failed_secu++;
 
                        t->be->be_counters.denied_resp++;
                        t->fe->fe_counters.denied_resp++;
@@ -5447,10 +5447,10 @@ int http_process_res_common(struct session *t, struct channel *rep, int an_bit,
                                t->listener->counters->denied_resp++;
 
                        Alert("Blocking cacheable cookie in response from instance %s, server %s.\n",
-                             t->be->id, target_srv(&t->target) ? target_srv(&t->target)->id : "<dispatch>");
+                             t->be->id, objt_server(t->target) ? objt_server(t->target)->id : "<dispatch>");
                        send_log(t->be, LOG_ALERT,
                                 "Blocking cacheable cookie in response from instance %s, server %s.\n",
-                                t->be->id, target_srv(&t->target) ? target_srv(&t->target)->id : "<dispatch>");
+                                t->be->id, objt_server(t->target) ? objt_server(t->target)->id : "<dispatch>");
                        goto return_srv_prx_502;
                }
 
@@ -5712,8 +5712,8 @@ int http_response_forward_body(struct session *s, struct channel *res, int an_bi
                if (!(s->flags & SN_ERR_MASK))
                        s->flags |= SN_ERR_SRVCL;
                s->be->be_counters.srv_aborts++;
-               if (target_srv(&s->target))
-                       target_srv(&s->target)->counters.srv_aborts++;
+               if (objt_server(s->target))
+                       objt_server(s->target)->counters.srv_aborts++;
                goto return_bad_res_stats_ok;
        }
 
@@ -5762,8 +5762,8 @@ int http_response_forward_body(struct session *s, struct channel *res, int an_bi
 
  return_bad_res: /* let's centralize all bad responses */
        s->be->be_counters.failed_resp++;
-       if (target_srv(&s->target))
-               target_srv(&s->target)->counters.failed_resp++;
+       if (objt_server(s->target))
+               objt_server(s->target)->counters.failed_resp++;
 
  return_bad_res_stats_ok:
        txn->rsp.msg_state = HTTP_MSG_ERROR;
@@ -5771,8 +5771,8 @@ int http_response_forward_body(struct session *s, struct channel *res, int an_bi
        stream_int_retnclose(res->cons, NULL);
        res->analysers = 0;
        s->req->analysers = 0; /* we're in data phase, we want to abort both directions */
-       if (target_srv(&s->target))
-               health_adjust(target_srv(&s->target), HANA_STATUS_HTTP_HDRRSP);
+       if (objt_server(s->target))
+               health_adjust(objt_server(s->target), HANA_STATUS_HTTP_HDRRSP);
 
        if (!(s->flags & SN_ERR_MASK))
                s->flags |= SN_ERR_PRXCOND;
@@ -5789,8 +5789,8 @@ int http_response_forward_body(struct session *s, struct channel *res, int an_bi
 
        s->fe->fe_counters.cli_aborts++;
        s->be->be_counters.cli_aborts++;
-       if (target_srv(&s->target))
-               target_srv(&s->target)->counters.cli_aborts++;
+       if (objt_server(s->target))
+               objt_server(s->target)->counters.cli_aborts++;
 
        if (!(s->flags & SN_ERR_MASK))
                s->flags |= SN_ERR_CLICL;
@@ -6166,7 +6166,7 @@ void manage_client_side_appsession(struct session *t, const char *buf, int len)
                                                txn->flags &= ~TX_CK_MASK;
                                                txn->flags |= (srv->state & SRV_RUNNING) ? TX_CK_VALID : TX_CK_DOWN;
                                                t->flags |= SN_DIRECT | SN_ASSIGNED;
-                                               set_target_server(&t->target, srv);
+                                               t->target = &srv->obj_type;
 
                                                break;
                                        } else {
@@ -6576,7 +6576,7 @@ void manage_client_side_cookies(struct session *t, struct channel *req)
                                                        txn->flags &= ~TX_CK_MASK;
                                                        txn->flags |= (srv->state & SRV_RUNNING) ? TX_CK_VALID : TX_CK_DOWN;
                                                        t->flags |= SN_DIRECT | SN_ASSIGNED;
-                                                       set_target_server(&t->target, srv);
+                                                       t->target = &srv->obj_type;
                                                        break;
                                                } else {
                                                        /* we found a server, but it's down,
@@ -7152,7 +7152,7 @@ void manage_server_side_cookies(struct session *t, struct channel *res)
                                }
                        }
 
-                       srv = target_srv(&t->target);
+                       srv = objt_server(t->target);
                        /* now check if we need to process it for persistence */
                        if (!(t->flags & SN_IGNORE_PRST) &&
                            (att_end - att_beg == t->be->cookie_len) && (t->be->cookie_name != NULL) &&
@@ -7289,7 +7289,7 @@ void manage_server_side_cookies(struct session *t, struct channel *res)
                        memcpy(asession->sessid, txn->sessid, t->be->appsession_len);
                        asession->sessid[t->be->appsession_len] = 0;
 
-                       server_id_len = strlen(target_srv(&t->target)->id) + 1;
+                       server_id_len = strlen(objt_server(t->target)->id) + 1;
                        if ((asession->serverid = pool_alloc2(apools.serverid)) == NULL) {
                                Alert("Not enough Memory process_srv():asession->serverid:malloc().\n");
                                send_log(t->be, LOG_ALERT, "Not enough Memory process_srv():asession->sessid:malloc().\n");
@@ -7297,7 +7297,7 @@ void manage_server_side_cookies(struct session *t, struct channel *res)
                                return;
                        }
                        asession->serverid[0] = '\0';
-                       memcpy(asession->serverid, target_srv(&t->target)->id, server_id_len);
+                       memcpy(asession->serverid, objt_server(t->target)->id, server_id_len);
 
                        asession->request_count = 0;
                        appsession_hash_insert(&(t->be->htbl_proxy), asession);
@@ -7582,7 +7582,7 @@ void http_capture_bad_message(struct error_snapshot *es, struct session *s,
 
        es->when = date; // user-visible date
        es->sid  = s->uniq_id;
-       es->srv  = target_srv(&s->target);
+       es->srv  = objt_server(s->target);
        es->oe   = other_end;
        es->src  = s->req->prod->conn->addr.from;
        es->state = state;
@@ -7775,7 +7775,7 @@ void http_reset_txn(struct session *s)
        s->be = s->fe;
        s->logs.logwait = s->fe->to_log;
        session_del_srv_conn(s);
-       clear_target(&s->target);
+       s->target = NULL;
        /* re-init store persistence */
        s->store_count = 0;
 
index 28df64bc2a5ec12556a7e57e1ec236e149c92070..e744c76759674afb1182549799c2d1a316e3c514 100644 (file)
@@ -220,7 +220,7 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
  * pointed to by conn->addr.from in case of transparent proxying. Normal source
  * bind addresses are still determined locally (due to the possible need of a
  * source port). conn->target may point either to a valid server or to a backend,
- * depending on conn->target.type. Only TARG_TYPE_PROXY and TARG_TYPE_SERVER are
+ * depending on conn->target. Only OBJ_TYPE_PROXY and OBJ_TYPE_SERVER are
  * supported. The <data> parameter is a boolean indicating whether there are data
  * waiting for being sent or not, in order to adjust data write polling and on
  * some platforms, the ability to avoid an empty initial ACK.
@@ -241,13 +241,13 @@ int tcp_connect_server(struct connection *conn, int data)
        struct server *srv;
        struct proxy *be;
 
-       switch (conn->target.type) {
-       case TARG_TYPE_PROXY:
-               be = conn->target.ptr.p;
+       switch (obj_type(conn->target)) {
+       case OBJ_TYPE_PROXY:
+               be = objt_proxy(conn->target);
                srv = NULL;
                break;
-       case TARG_TYPE_SERVER:
-               srv = conn->target.ptr.s;
+       case OBJ_TYPE_SERVER:
+               srv = objt_server(conn->target);
                be = srv->proxy;
                break;
        default:
index 2c710bbbc15383ce47b4a0b36c48c8e947303170..914d97940dc92078c94e4880c4f022764ccfb0b8 100644 (file)
@@ -26,6 +26,7 @@
 #include <common/time.h>
 
 #include <types/global.h>
+#include <types/obj_type.h>
 #include <types/peers.h>
 
 #include <proto/backend.h>
@@ -425,6 +426,7 @@ int proxy_cfg_ensure_no_http(struct proxy *curproxy)
 void init_new_proxy(struct proxy *p)
 {
        memset(p, 0, sizeof(struct proxy));
+       p->obj_type = OBJ_TYPE_PROXY;
        LIST_INIT(&p->pendconns);
        LIST_INIT(&p->acl);
        LIST_INIT(&p->http_req_rules);
index dd6e96218b81a6f5c6b3d4403094eb9d06a4f4a1..abc0f8c0023e694d9ca8b4fe679284fb01729f27 100644 (file)
@@ -122,7 +122,7 @@ struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px)
 
        /* we want to note that the session has now been assigned a server */
        sess->flags |= SN_ASSIGNED;
-       set_target_server(&sess->target, srv);
+       sess->target = &srv->obj_type;
        session_add_srv_conn(sess, srv);
        srv->served++;
        if (px->lbprm.server_take_conn)
@@ -148,7 +148,7 @@ struct pendconn *pendconn_add(struct session *sess)
 
        sess->pend_pos = p;
        p->sess = sess;
-       p->srv = srv = target_srv(&sess->target);
+       p->srv = srv = objt_server(sess->target);
 
        if (sess->flags & SN_ASSIGNED && srv) {
                LIST_ADDQ(&srv->pendconns, &p->list);
index 3d28677f3e61ec99056257a30fea499e3f72c2cb..0b0a4ec5f03bd6665d4e2694a89c41946f3fb02c 100644 (file)
@@ -110,7 +110,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        s->si[0].conn->ctrl = l->proto;
        s->si[0].conn->flags = CO_FL_NONE;
        s->si[0].conn->addr.from = *addr;
-       set_target_client(&s->si[0].conn->target, l);
+       s->si[0].conn->target = &l->obj_type;
 
        s->logs.accept_date = date; /* user-visible date for logging */
        s->logs.tv_accept = now;  /* corrected date for internal use */
@@ -415,7 +415,7 @@ int session_complete(struct session *s)
        s->si[1].err_loc   = NULL;
        s->si[1].release   = NULL;
        s->si[1].send_proxy_ofs = 0;
-       clear_target(&s->si[1].conn->target);
+       s->si[1].conn->target = NULL;
        si_prepare_embedded(&s->si[1]);
        s->si[1].exp       = TICK_ETERNITY;
        s->si[1].flags     = SI_FL_NONE;
@@ -424,7 +424,7 @@ int session_complete(struct session *s)
                s->si[1].flags |= SI_FL_INDEP_STR;
 
        session_init_srv_conn(s);
-       clear_target(&s->target);
+       s->target = NULL;
        s->pend_pos = NULL;
 
        /* init store persistence */
@@ -548,13 +548,13 @@ static void session_free(struct session *s)
        if (s->pend_pos)
                pendconn_free(s->pend_pos);
 
-       if (target_srv(&s->target)) { /* there may be requests left pending in queue */
+       if (objt_server(s->target)) { /* there may be requests left pending in queue */
                if (s->flags & SN_CURR_SESS) {
                        s->flags &= ~SN_CURR_SESS;
-                       target_srv(&s->target)->cur_sess--;
+                       objt_server(s->target)->cur_sess--;
                }
-               if (may_dequeue_tasks(target_srv(&s->target), s->be))
-                       process_srv_queue(target_srv(&s->target));
+               if (may_dequeue_tasks(objt_server(s->target), s->be))
+                       process_srv_queue(objt_server(s->target));
        }
 
        if (unlikely(s->srv_conn)) {
@@ -653,8 +653,8 @@ void session_process_counters(struct session *s)
 
                        s->be->be_counters.bytes_in                     += bytes;
 
-                       if (target_srv(&s->target))
-                               target_srv(&s->target)->counters.bytes_in               += bytes;
+                       if (objt_server(s->target))
+                               objt_server(s->target)->counters.bytes_in               += bytes;
 
                        if (s->listener->counters)
                                s->listener->counters->bytes_in         += bytes;
@@ -703,8 +703,8 @@ void session_process_counters(struct session *s)
 
                        s->be->be_counters.bytes_out                    += bytes;
 
-                       if (target_srv(&s->target))
-                               target_srv(&s->target)->counters.bytes_out              += bytes;
+                       if (objt_server(s->target))
+                               objt_server(s->target)->counters.bytes_out              += bytes;
 
                        if (s->listener->counters)
                                s->listener->counters->bytes_out        += bytes;
@@ -773,7 +773,7 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si
                        si->state    = SI_ST_EST;
                        si->err_type = SI_ET_DATA_ERR;
                        si->ib->flags |= CF_READ_ERROR | CF_WRITE_ERROR;
-                       si->err_loc = target_srv(&s->target);
+                       si->err_loc = objt_server(s->target);
                        return 1;
                }
                si->exp   = TICK_ETERNITY;
@@ -787,7 +787,7 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si
                if (si->err_type)
                        return 0;
 
-               si->err_loc = target_srv(&s->target);
+               si->err_loc = objt_server(s->target);
                if (si->flags & SI_FL_ERR)
                        si->err_type = SI_ET_CONN_ERR;
                else
@@ -803,7 +803,7 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si
                /* give up */
                si_shutw(si);
                si->err_type |= SI_ET_CONN_ABRT;
-               si->err_loc  = target_srv(&s->target);
+               si->err_loc  = objt_server(s->target);
                if (s->srv_error)
                        s->srv_error(s, si);
                return 1;
@@ -836,12 +836,12 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si
 static int sess_update_st_cer(struct session *s, struct stream_interface *si)
 {
        /* we probably have to release last session from the server */
-       if (target_srv(&s->target)) {
-               health_adjust(target_srv(&s->target), HANA_STATUS_L4_ERR);
+       if (objt_server(s->target)) {
+               health_adjust(objt_server(s->target), HANA_STATUS_L4_ERR);
 
                if (s->flags & SN_CURR_SESS) {
                        s->flags &= ~SN_CURR_SESS;
-                       target_srv(&s->target)->cur_sess--;
+                       objt_server(s->target)->cur_sess--;
                }
        }
 
@@ -850,15 +850,15 @@ static int sess_update_st_cer(struct session *s, struct stream_interface *si)
        if (si->conn_retries < 0) {
                if (!si->err_type) {
                        si->err_type = SI_ET_CONN_ERR;
-                       si->err_loc = target_srv(&s->target);
+                       si->err_loc = objt_server(s->target);
                }
 
-               if (target_srv(&s->target))
-                       target_srv(&s->target)->counters.failed_conns++;
+               if (objt_server(s->target))
+                       objt_server(s->target)->counters.failed_conns++;
                s->be->be_counters.failed_conns++;
                sess_change_server(s, NULL);
-               if (may_dequeue_tasks(target_srv(&s->target), s->be))
-                       process_srv_queue(target_srv(&s->target));
+               if (may_dequeue_tasks(objt_server(s->target), s->be))
+                       process_srv_queue(objt_server(s->target));
 
                /* shutw is enough so stop a connecting socket */
                si_shutw(si);
@@ -877,17 +877,17 @@ static int sess_update_st_cer(struct session *s, struct stream_interface *si)
         * bit to ignore any persistence cookie. We won't count a retry nor a
         * redispatch yet, because this will depend on what server is selected.
         */
-       if (target_srv(&s->target) && si->conn_retries == 0 &&
+       if (objt_server(s->target) && si->conn_retries == 0 &&
            s->be->options & PR_O_REDISP && !(s->flags & SN_FORCE_PRST)) {
                sess_change_server(s, NULL);
-               if (may_dequeue_tasks(target_srv(&s->target), s->be))
-                       process_srv_queue(target_srv(&s->target));
+               if (may_dequeue_tasks(objt_server(s->target), s->be))
+                       process_srv_queue(objt_server(s->target));
 
                s->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
                si->state = SI_ST_REQ;
        } else {
-               if (target_srv(&s->target))
-                       target_srv(&s->target)->counters.retries++;
+               if (objt_server(s->target))
+                       objt_server(s->target)->counters.retries++;
                s->be->be_counters.retries++;
                si->state = SI_ST_ASS;
        }
@@ -919,8 +919,8 @@ static void sess_establish(struct session *s, struct stream_interface *si)
        struct channel *req = si->ob;
        struct channel *rep = si->ib;
 
-       if (target_srv(&s->target))
-               health_adjust(target_srv(&s->target), HANA_STATUS_L4_OK);
+       if (objt_server(s->target))
+               health_adjust(objt_server(s->target), HANA_STATUS_L4_OK);
 
        if (s->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
                /* if the user wants to log as soon as possible, without counting
@@ -955,7 +955,7 @@ static void sess_establish(struct session *s, struct stream_interface *si)
  */
 static void sess_update_stream_int(struct session *s, struct stream_interface *si)
 {
-       struct server *srv = target_srv(&s->target);
+       struct server *srv = objt_server(s->target);
 
        DPRINTF(stderr,"[%u] %s: sess=%p rq=%p, rp=%p, exp(r,w)=%u,%u rqf=%08x rpf=%08x rqh=%d rqt=%d rph=%d rpt=%d cs=%d ss=%d\n",
                now_ms, __FUNCTION__,
@@ -970,7 +970,7 @@ static void sess_update_stream_int(struct session *s, struct stream_interface *s
                int conn_err;
 
                conn_err = connect_server(s);
-               srv = target_srv(&s->target);
+               srv = objt_server(s->target);
 
                if (conn_err == SN_ERR_NONE) {
                        /* state = SI_ST_CON now */
@@ -1314,7 +1314,7 @@ static int process_server_rules(struct session *s, struct channel *req, int an_b
                                    (px->options & PR_O_PERSIST) ||
                                    (s->flags & SN_FORCE_PRST)) {
                                        s->flags |= SN_DIRECT | SN_ASSIGNED;
-                                       set_target_server(&s->target, srv);
+                                       s->target = &srv->obj_type;
                                        break;
                                }
                                /* if the server is not UP, let's go on with next rules
@@ -1392,7 +1392,7 @@ static int process_sticking_rules(struct session *s, struct channel *req, int an
                                                            (px->options & PR_O_PERSIST) ||
                                                            (s->flags & SN_FORCE_PRST)) {
                                                                s->flags |= SN_DIRECT | SN_ASSIGNED;
-                                                               set_target_server(&s->target, srv);
+                                                               s->target = &srv->obj_type;
                                                        }
                                                }
                                        }
@@ -1488,7 +1488,7 @@ static int process_store_rules(struct session *s, struct channel *rep, int an_bi
                struct stksess *ts;
                void *ptr;
 
-               if (target_srv(&s->target) && target_srv(&s->target)->state & SRV_NON_STICK) {
+               if (objt_server(s->target) && objt_server(s->target)->state & SRV_NON_STICK) {
                        stksess_free(s->store[i].table, s->store[i].ts);
                        s->store[i].ts = NULL;
                        continue;
@@ -1505,7 +1505,7 @@ static int process_store_rules(struct session *s, struct channel *rep, int an_bi
 
                s->store[i].ts = NULL;
                ptr = stktable_data_ptr(s->store[i].table, ts, STKTABLE_DT_SERVER_ID);
-               stktable_data_cast(ptr, server_id) = target_srv(&s->target)->puid;
+               stktable_data_cast(ptr, server_id) = objt_server(s->target)->puid;
        }
        s->store_count = 0; /* everything is stored */
 
@@ -1621,7 +1621,7 @@ struct task *process_session(struct task *t)
         * the client cannot have connect (hence retryable) errors. Also, the
         * connection setup code must be able to deal with any type of abort.
         */
-       srv = target_srv(&s->target);
+       srv = objt_server(s->target);
        if (unlikely(s->si[0].flags & SI_FL_ERR)) {
                if (s->si[0].state == SI_ST_EST || s->si[0].state == SI_ST_DIS) {
                        si_shutr(&s->si[0]);
@@ -1706,7 +1706,7 @@ struct task *process_session(struct task *t)
         */
        if (unlikely(s->req->cons->state == SI_ST_DIS)) {
                s->req->cons->state = SI_ST_CLO;
-               srv = target_srv(&s->target);
+               srv = objt_server(s->target);
                if (srv) {
                        if (s->flags & SN_CURR_SESS) {
                                s->flags &= ~SN_CURR_SESS;
@@ -1988,7 +1988,7 @@ struct task *process_session(struct task *t)
         * we're just in a data phase here since it means we have not
         * seen any analyser who could set an error status.
         */
-       srv = target_srv(&s->target);
+       srv = objt_server(s->target);
        if (unlikely(!(s->flags & SN_ERR_MASK))) {
                if (s->req->flags & (CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) {
                        /* Report it if the client got an error or a read timeout expired */
@@ -2148,7 +2148,7 @@ struct task *process_session(struct task *t)
                                 */
                                s->req->cons->state = SI_ST_REQ; /* new connection requested */
                                s->req->cons->conn_retries = s->be->conn_retries;
-                               if (unlikely(s->req->cons->conn->target.type == TARG_TYPE_APPLET &&
+                               if (unlikely(obj_type(s->req->cons->conn->target) == OBJ_TYPE_APPLET &&
                                             !(si_ctrl(s->req->cons) && si_ctrl(s->req->cons)->connect))) {
                                        s->req->cons->state = SI_ST_EST; /* connection established */
                                        s->rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
@@ -2177,7 +2177,7 @@ struct task *process_session(struct task *t)
                        if (s->si[1].state == SI_ST_REQ)
                                sess_prepare_conn_req(s, &s->si[1]);
 
-                       srv = target_srv(&s->target);
+                       srv = objt_server(s->target);
                        if (s->si[1].state == SI_ST_ASS && srv && srv->rdr_len && (s->flags & SN_REDIRECTABLE))
                                perform_http_redirect(s, &s->si[1]);
                } while (s->si[1].state == SI_ST_ASS);
@@ -2187,7 +2187,7 @@ struct task *process_session(struct task *t)
                if ((s->flags & SN_BE_ASSIGNED) &&
                    (s->be->mode == PR_MODE_HTTP) &&
                    (s->be->server_id_hdr_name != NULL)) {
-                       http_send_name_header(&s->txn, s->be, target_srv(&s->target)->id);
+                       http_send_name_header(&s->txn, s->be, objt_server(s->target)->id);
                }
        }
 
@@ -2327,10 +2327,10 @@ struct task *process_session(struct task *t)
                if ((s->fe->options & PR_O_CONTSTATS) && (s->flags & SN_BE_ASSIGNED))
                        session_process_counters(s);
 
-               if (s->rep->cons->state == SI_ST_EST && s->rep->cons->conn->target.type != TARG_TYPE_APPLET)
+               if (s->rep->cons->state == SI_ST_EST && obj_type(s->rep->cons->conn->target) != OBJ_TYPE_APPLET)
                        si_update(s->rep->cons);
 
-               if (s->req->cons->state == SI_ST_EST && s->req->cons->conn->target.type != TARG_TYPE_APPLET)
+               if (s->req->cons->state == SI_ST_EST && obj_type(s->req->cons->conn->target) != OBJ_TYPE_APPLET)
                        si_update(s->req->cons);
 
                s->req->flags &= ~(CF_READ_NULL|CF_READ_PARTIAL|CF_WRITE_NULL|CF_WRITE_PARTIAL|CF_READ_ATTACHED);
@@ -2357,12 +2357,12 @@ struct task *process_session(struct task *t)
                /* Call the stream interfaces' I/O handlers when embedded.
                 * Note that this one may wake the task up again.
                 */
-               if (s->req->cons->conn->target.type == TARG_TYPE_APPLET ||
-                   s->rep->cons->conn->target.type == TARG_TYPE_APPLET) {
-                       if (s->req->cons->conn->target.type == TARG_TYPE_APPLET)
-                               s->req->cons->conn->target.ptr.a->fct(s->req->cons);
-                       if (s->rep->cons->conn->target.type == TARG_TYPE_APPLET)
-                               s->rep->cons->conn->target.ptr.a->fct(s->rep->cons);
+               if (obj_type(s->req->cons->conn->target) == OBJ_TYPE_APPLET ||
+                   obj_type(s->rep->cons->conn->target) == OBJ_TYPE_APPLET) {
+                       if (objt_applet(s->req->cons->conn->target))
+                               objt_applet(s->req->cons->conn->target)->fct(s->req->cons);
+                       if (objt_applet(s->rep->cons->conn->target))
+                               objt_applet(s->rep->cons->conn->target)->fct(s->rep->cons);
                        if (task_in_rq(t)) {
                                /* If we woke up, we don't want to requeue the
                                 * task to the wait queue, but rather requeue
index bc4afc6fd007eb1dbeff39cd514be42e07510e66..f19e0a74b9886458cf7eeacedf8af56ed62c180f 100644 (file)
@@ -125,7 +125,7 @@ int ssl_sock_verifycbk(int ok, X509_STORE_CTX *x_store)
                        conn->xprt_st |= SSL_SOCK_CAEDEPTH_TO_ST(depth);
                }
 
-               if (target_client(&conn->target)->bind_conf->ca_ignerr & (1ULL << err))
+               if (objt_listener(conn->target)->bind_conf->ca_ignerr & (1ULL << err))
                        return 1;
 
                return 0;
@@ -135,7 +135,7 @@ int ssl_sock_verifycbk(int ok, X509_STORE_CTX *x_store)
                conn->xprt_st |= SSL_SOCK_CRTERROR_TO_ST(err);
 
        /* check if certificate error needs to be ignored */
-       if (target_client(&conn->target)->bind_conf->crt_ignerr & (1ULL << err))
+       if (objt_listener(conn->target)->bind_conf->crt_ignerr & (1ULL << err))
                return 1;
 
        return 0;
@@ -798,15 +798,15 @@ static int ssl_sock_init(struct connection *conn)
 
        /* If it is in client mode initiate SSL session
           in connect state otherwise accept state */
-       if (target_srv(&conn->target)) {
+       if (objt_server(conn->target)) {
                /* Alloc a new SSL session ctx */
-               conn->xprt_ctx = SSL_new(target_srv(&conn->target)->ssl_ctx.ctx);
+               conn->xprt_ctx = SSL_new(objt_server(conn->target)->ssl_ctx.ctx);
                if (!conn->xprt_ctx)
                        return -1;
 
                SSL_set_connect_state(conn->xprt_ctx);
-               if (target_srv(&conn->target)->ssl_ctx.reused_sess)
-                       SSL_set_session(conn->xprt_ctx, target_srv(&conn->target)->ssl_ctx.reused_sess);
+               if (objt_server(conn->target)->ssl_ctx.reused_sess)
+                       SSL_set_session(conn->xprt_ctx, objt_server(conn->target)->ssl_ctx.reused_sess);
 
                /* set fd on SSL session context */
                SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd);
@@ -817,9 +817,9 @@ static int ssl_sock_init(struct connection *conn)
                sslconns++;
                return 0;
        }
-       else if (target_client(&conn->target)) {
+       else if (objt_listener(conn->target)) {
                /* Alloc a new SSL session ctx */
-               conn->xprt_ctx = SSL_new(target_client(&conn->target)->bind_conf->default_ctx);
+               conn->xprt_ctx = SSL_new(objt_listener(conn->target)->bind_conf->default_ctx);
                if (!conn->xprt_ctx)
                        return -1;
 
@@ -893,13 +893,13 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
        }
 
        /* Handshake succeeded */
-       if (target_srv(&conn->target)) {
+       if (objt_server(conn->target)) {
                if (!SSL_session_reused(conn->xprt_ctx)) {
                        /* check if session was reused, if not store current session on server for reuse */
-                       if (target_srv(&conn->target)->ssl_ctx.reused_sess)
-                               SSL_SESSION_free(target_srv(&conn->target)->ssl_ctx.reused_sess);
+                       if (objt_server(conn->target)->ssl_ctx.reused_sess)
+                               SSL_SESSION_free(objt_server(conn->target)->ssl_ctx.reused_sess);
 
-                       target_srv(&conn->target)->ssl_ctx.reused_sess = SSL_get1_session(conn->xprt_ctx);
+                       objt_server(conn->target)->ssl_ctx.reused_sess = SSL_get1_session(conn->xprt_ctx);
                }
        }
 
@@ -909,9 +909,9 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
 
  out_error:
        /* free resumed session if exists */
-       if (target_srv(&conn->target) && target_srv(&conn->target)->ssl_ctx.reused_sess) {
-               SSL_SESSION_free(target_srv(&conn->target)->ssl_ctx.reused_sess);
-               target_srv(&conn->target)->ssl_ctx.reused_sess = NULL;
+       if (objt_server(conn->target) && objt_server(conn->target)->ssl_ctx.reused_sess) {
+               SSL_SESSION_free(objt_server(conn->target)->ssl_ctx.reused_sess);
+               objt_server(conn->target)->ssl_ctx.reused_sess = NULL;
        }
 
        /* Fail on all other handshake errors */
index bcedcb095a3378180969c016850fd1392099eea5..c84763274bc658740d29182e31cdcb643f100403 100644 (file)
@@ -406,7 +406,7 @@ struct task *stream_int_register_handler(struct stream_interface *si, struct si_
        DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner);
 
        si_prepare_embedded(si);
-       set_target_applet(&si->conn->target, app);
+       si->conn->target = &app->obj_type;
        si->release = app->release;
        si->flags |= SI_FL_WAIT_DATA;
        return si->owner;
@@ -419,7 +419,7 @@ void stream_int_unregister_handler(struct stream_interface *si)
 {
        si->release = NULL;
        si->owner = NULL;
-       clear_target(&si->conn->target);
+       si->conn->target = NULL;
 }
 
 /* This callback is used to send a valid PROXY protocol line to a socket being