MINOR: stream_interface: introduce a new "struct connection" type
We start to move everything needed to manage a connection to a special
entity "struct connection". We have the data layer operations and the
control operations there. We'll also have more info in the future such
as file descriptors and applet contexts, so that in the end it becomes
detachable from the stream interface, which will allow connections to
be reused between sessions.
For now on, we start with minimal changes.
diff --git a/src/backend.c b/src/backend.c
index 9a5b196..31f1a0f 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -984,14 +984,14 @@
/* set the correct protocol on the output stream interface */
if (s->target.type == TARG_TYPE_SERVER) {
- s->req->cons->proto = target_srv(&s->target)->proto;
+ s->req->cons->conn.ctrl = target_srv(&s->target)->proto;
stream_interface_prepare(s->req->cons, target_srv(&s->target)->sock);
}
else if (s->target.type == TARG_TYPE_PROXY) {
/* proxies exclusively run on sock_raw right now */
- s->req->cons->proto = protocol_by_family(s->req->cons->addr.to.ss_family);
+ s->req->cons->conn.ctrl = protocol_by_family(s->req->cons->addr.to.ss_family);
stream_interface_prepare(s->req->cons, &sock_raw);
- if (!s->req->cons->proto)
+ if (!si_ctrl(s->req->cons))
return SN_ERR_INTERNAL;
}
else
@@ -1010,7 +1010,7 @@
if (s->fe->options2 & PR_O2_SRC_ADDR)
s->req->cons->flags |= SI_FL_SRC_ADDR;
- err = s->req->cons->proto->connect(s->req->cons);
+ err = si_connect(s->req->cons);
if (err != SN_ERR_NONE)
return err;