]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: add a pointer to the connection owner
authorWilly Tarreau <w@1wt.eu>
Thu, 27 Sep 2012 20:14:33 +0000 (22:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 27 Sep 2012 22:01:22 +0000 (00:01 +0200)
This will be needed to find the stream interface from the connection
once they're detached, but in the more immediate term, we'll need this
for health checks since they don't use a stream interface.

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

index 94f1c83b82f9981fc2d7970483b29a71d6cf0341..7f130d80963a687ffebd13c6c74f609783ce3f45 100644 (file)
@@ -413,14 +413,16 @@ static inline void conn_get_to_addr(struct connection *conn)
 }
 
 /* prepares a connection with the appropriate app_cb, ctrl and data layers. The
- * data state and context are set to 0.
+ * data state and context are set to 0, and the connection's owner is set.
  */
 static inline void conn_prepare(struct connection *conn, const struct app_cb *app,
-                                const struct protocol *ctrl, const struct data_ops *data)
+                                const struct protocol *ctrl, const struct data_ops *data,
+                                void *owner)
 {
        conn->app_cb = app;
        conn->ctrl = ctrl;
        conn->data = data;
+       conn->owner = owner;
        conn->data_st = 0;
        conn->data_ctx = NULL;
 }
index f68b6ba0691d1774d304afdf43f1a5663064bfd5..c11ce3892eede2e60e80f64d1049e377967989d6 100644 (file)
@@ -67,19 +67,19 @@ static inline int si_fd(struct stream_interface *si)
 static inline void si_prepare_conn(struct stream_interface *si, const struct protocol *ctrl, const struct data_ops *ops)
 {
        si->ops = &si_conn_ops;
-       conn_prepare(&si->conn, &si_conn_cb, ctrl, ops);
+       conn_prepare(&si->conn, &si_conn_cb, ctrl, ops, si);
 }
 
 static inline void si_prepare_embedded(struct stream_interface *si)
 {
        si->ops = &si_embedded_ops;
-       conn_prepare(&si->conn, NULL, NULL, NULL);
+       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);
+       conn_prepare(&si->conn, NULL, NULL, NULL, si);
 }
 
 /* Sends a shutr to the connection using the data layer */
index 8a1b8ee5052b03acc2b2b655c0bd5d67394ba6ca..66ab11800323835807ac479952340de13608e16a 100644 (file)
@@ -198,6 +198,7 @@ struct connection {
        const struct data_ops *data;  /* operations at the data layer */
        const struct protocol *ctrl;  /* operations at the socket layer */
        const struct app_cb *app_cb;  /* application layer callbacks */
+       void *owner;                  /* pointer to upper layer's entity (eg: stream interface) */
        union {                       /* definitions which depend on connection type */
                struct {              /*** information used by socket-based connections ***/
                        int fd;       /* file descriptor for a stream driver when known */
@@ -209,7 +210,7 @@ struct connection {
        struct target 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 if SN_FRT_ADDR_SET is set, or address to connect to */
+               struct sockaddr_storage to;     /* address reached by the client, or address to connect to */
        } addr; /* addresses of the remote side, client for producer and server for consumer */
 };