REORG: connection: rename the data layer the "transport layer"
While working on the changes required to make the health checks use the
new connections, it started to become obvious that some naming was not
logical at all in the connections. Specifically, it is not logical to
call the "data layer" the layer which is in charge for all the handshake
and which does not yet provide a data layer once established until a
session has allocated all the required buffers.
In fact, it's more a transport layer, which makes much more sense. The
transport layer offers a medium on which data can transit, and it offers
the functions to move these data when the upper layer requests this. And
it is the upper layer which iterates over the transport layer's functions
to move data which should be called the data layer.
The use case where it's obvious is with embryonic sessions : an incoming
SSL connection is accepted. Only the connection is allocated, not the
buffers nor stream interface, etc... The connection handles the SSL
handshake by itself. Once this handshake is complete, we can't use the
data functions because the buffers and stream interface are not there
yet. Hence we have to first call a specific function to complete the
session initialization, after which we'll be able to use the data
functions. This clearly proves that SSL here is only a transport layer
and that the stream interface constitutes the data layer.
A similar change will be performed to rename app_cb => data, but the
two could not be in the same commit for obvious reasons.
diff --git a/src/peers.c b/src/peers.c
index 62329dc..f030613 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -184,9 +184,9 @@
{
struct task *t = (struct task *)si->owner;
struct session *s = (struct session *)t->context;
- struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
+ struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
- /* si->conn.data_ctx is not a peer session */
+ /* si->conn.xprt_ctx is not a peer session */
if (si->applet.st0 < PEER_SESSION_SENDSUCCESS)
return;
@@ -226,7 +226,7 @@
switchstate:
switch(si->applet.st0) {
case PEER_SESSION_ACCEPT:
- si->conn.data_ctx = NULL;
+ si->conn.xprt_ctx = NULL;
si->applet.st0 = PEER_SESSION_GETVERSION;
/* fall through */
case PEER_SESSION_GETVERSION:
@@ -332,12 +332,12 @@
goto switchstate;
}
- si->conn.data_ctx = curpeer;
+ si->conn.xprt_ctx = curpeer;
si->applet.st0 = PEER_SESSION_GETTABLE;
/* fall through */
}
case PEER_SESSION_GETTABLE: {
- struct peer *curpeer = (struct peer *)si->conn.data_ctx;
+ struct peer *curpeer = (struct peer *)si->conn.xprt_ctx;
struct shared_table *st;
struct peer_session *ps = NULL;
unsigned long key_type;
@@ -348,12 +348,12 @@
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
- si->conn.data_ctx = NULL;
+ si->conn.xprt_ctx = NULL;
si->applet.st0 = PEER_SESSION_END;
goto switchstate;
}
- /* Re init si->conn.data_ctx to null, to handle correctly a release case */
- si->conn.data_ctx = NULL;
+ /* Re init si->conn.xprt_ctx to null, to handle correctly a release case */
+ si->conn.xprt_ctx = NULL;
if (trash[reql-1] != '\n') {
/* Incomplete line, we quit */
@@ -379,7 +379,7 @@
p = strchr(p+1, ' ');
if (!p) {
- si->conn.data_ctx = NULL;
+ si->conn.xprt_ctx = NULL;
si->applet.st0 = PEER_SESSION_EXIT;
si->applet.st1 = PEER_SESSION_ERRPROTO;
goto switchstate;
@@ -438,12 +438,12 @@
goto switchstate;
}
- si->conn.data_ctx = ps;
+ si->conn.xprt_ctx = ps;
si->applet.st0 = PEER_SESSION_SENDSUCCESS;
/* fall through */
}
case PEER_SESSION_SENDSUCCESS:{
- struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
+ struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
repl = snprintf(trash, trashlen, "%d\n", PEER_SESSION_SUCCESSCODE);
repl = bi_putblk(si->ib, trash, repl);
@@ -493,7 +493,7 @@
goto switchstate;
}
case PEER_SESSION_CONNECT: {
- struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
+ struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
/* Send headers */
repl = snprintf(trash, trashlen,
@@ -523,7 +523,7 @@
/* fall through */
}
case PEER_SESSION_GETSTATUS: {
- struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
+ struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
if (si->ib->flags & CF_WRITE_PARTIAL)
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
@@ -594,7 +594,7 @@
/* fall through */
}
case PEER_SESSION_WAITMSG: {
- struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
+ struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
char c;
int totl = 0;
@@ -1063,7 +1063,7 @@
/* call release to reinit resync states if needed */
peer_session_release(oldsi);
oldsi->applet.st0 = PEER_SESSION_END;
- oldsi->conn.data_ctx = NULL;
+ oldsi->conn.xprt_ctx = NULL;
task_wakeup(session->task, TASK_WOKEN_MSG);
}
@@ -1078,7 +1078,7 @@
/* 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->si[1].conn.data_ctx = s;
+ s->si[1].conn.xprt_ctx = s;
s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
tv_zero(&s->logs.tv_request);
@@ -1164,7 +1164,7 @@
stream_int_register_handler(&s->si[0], &peer_applet);
s->si[0].applet.st0 = PEER_SESSION_CONNECT;
- s->si[0].conn.data_ctx = (void *)ps;
+ s->si[0].conn.xprt_ctx = (void *)ps;
s->si[1].conn.t.sock.fd = -1; /* just to help with debugging */
s->si[1].conn.flags = CO_FL_NONE;
@@ -1176,7 +1176,7 @@
s->si[1].release = NULL;
s->si[1].send_proxy_ofs = 0;
set_target_proxy(&s->si[1].conn.target, s->be);
- si_prepare_conn(&s->si[1], peer->proto, peer->data);
+ si_prepare_conn(&s->si[1], peer->proto, peer->xprt);
s->si[1].exp = TICK_ETERNITY;
s->si[1].flags = SI_FL_NONE;
if (s->be->options2 & PR_O2_INDEPSTR)