REORG: stream_interface: create a struct sock_ops to hold socket operations
These operators are used regardless of the socket protocol family. Move
them to a "sock_ops" struct. ->read and ->write have been moved there too
as they have no reason to remain at the protocol level.
diff --git a/src/session.c b/src/session.c
index f8b6516..fabba1f 100644
--- a/src/session.c
+++ b/src/session.c
@@ -200,8 +200,8 @@
s->si[1].get_src = NULL;
s->si[1].get_dst = NULL;
clear_target(&s->si[1].target);
- s->si[1].shutr = stream_int_shutr;
- s->si[1].shutw = stream_int_shutw;
+ s->si[1].sock.shutr= stream_int_shutr;
+ s->si[1].sock.shutw= stream_int_shutw;
s->si[1].exp = TICK_ETERNITY;
s->si[1].flags = SI_FL_NONE;
@@ -573,7 +573,7 @@
(((req->flags & (BF_OUT_EMPTY|BF_WRITE_ACTIVITY)) == BF_OUT_EMPTY) ||
s->be->options & PR_O_ABRT_CLOSE)))) {
/* give up */
- si->shutw(si);
+ si->sock.shutw(si);
si->err_type |= SI_ET_CONN_ABRT;
si->err_loc = target_srv(&s->target);
si->flags &= ~SI_FL_CAP_SPLICE;
@@ -634,7 +634,7 @@
process_srv_queue(target_srv(&s->target));
/* shutw is enough so stop a connecting socket */
- si->shutw(si);
+ si->sock.shutw(si);
si->ob->flags |= BF_WRITE_ERROR;
si->ib->flags |= BF_READ_ERROR;
@@ -773,8 +773,8 @@
process_srv_queue(srv);
/* Failed and not retryable. */
- si->shutr(si);
- si->shutw(si);
+ si->sock.shutr(si);
+ si->sock.shutw(si);
si->ob->flags |= BF_WRITE_ERROR;
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
@@ -822,8 +822,8 @@
if (srv)
srv->counters.failed_conns++;
s->be->be_counters.failed_conns++;
- si->shutr(si);
- si->shutw(si);
+ si->sock.shutr(si);
+ si->sock.shutw(si);
si->ob->flags |= BF_WRITE_TIMEOUT;
if (!si->err_type)
si->err_type = SI_ET_QUEUE_TO;
@@ -840,8 +840,8 @@
/* give up */
si->exp = TICK_ETERNITY;
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
- si->shutr(si);
- si->shutw(si);
+ si->sock.shutr(si);
+ si->sock.shutw(si);
si->err_type |= SI_ET_QUEUE_ABRT;
si->state = SI_ST_CLO;
if (s->srv_error)
@@ -859,8 +859,8 @@
(si->ob->flags & BF_OUT_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
/* give up */
si->exp = TICK_ETERNITY;
- si->shutr(si);
- si->shutw(si);
+ si->sock.shutr(si);
+ si->sock.shutw(si);
si->err_type |= SI_ET_CONN_ABRT;
si->state = SI_ST_CLO;
if (s->srv_error)
@@ -938,8 +938,8 @@
return;
/* we did not get any server, let's check the cause */
- si->shutr(si);
- si->shutw(si);
+ si->sock.shutr(si);
+ si->sock.shutw(si);
si->ob->flags |= BF_WRITE_ERROR;
if (!si->err_type)
si->err_type = SI_ET_CONN_OTHER;
@@ -1352,21 +1352,21 @@
if (unlikely((s->req->flags & (BF_SHUTW|BF_WRITE_TIMEOUT)) == BF_WRITE_TIMEOUT)) {
s->req->cons->flags |= SI_FL_NOLINGER;
- s->req->cons->shutw(s->req->cons);
+ s->req->cons->sock.shutw(s->req->cons);
}
if (unlikely((s->req->flags & (BF_SHUTR|BF_READ_TIMEOUT)) == BF_READ_TIMEOUT))
- s->req->prod->shutr(s->req->prod);
+ s->req->prod->sock.shutr(s->req->prod);
buffer_check_timeouts(s->rep);
if (unlikely((s->rep->flags & (BF_SHUTW|BF_WRITE_TIMEOUT)) == BF_WRITE_TIMEOUT)) {
s->rep->cons->flags |= SI_FL_NOLINGER;
- s->rep->cons->shutw(s->rep->cons);
+ s->rep->cons->sock.shutw(s->rep->cons);
}
if (unlikely((s->rep->flags & (BF_SHUTR|BF_READ_TIMEOUT)) == BF_READ_TIMEOUT))
- s->rep->prod->shutr(s->rep->prod);
+ s->rep->prod->sock.shutr(s->rep->prod);
}
/* 1b: check for low-level errors reported at the stream interface.
@@ -1379,8 +1379,8 @@
srv = target_srv(&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) {
- s->si[0].shutr(&s->si[0]);
- s->si[0].shutw(&s->si[0]);
+ s->si[0].sock.shutr(&s->si[0]);
+ s->si[0].sock.shutw(&s->si[0]);
stream_int_report_error(&s->si[0]);
if (!(s->req->analysers) && !(s->rep->analysers)) {
s->be->be_counters.cli_aborts++;
@@ -1397,8 +1397,8 @@
if (unlikely(s->si[1].flags & SI_FL_ERR)) {
if (s->si[1].state == SI_ST_EST || s->si[1].state == SI_ST_DIS) {
- s->si[1].shutr(&s->si[1]);
- s->si[1].shutw(&s->si[1]);
+ s->si[1].sock.shutr(&s->si[1]);
+ s->si[1].sock.shutw(&s->si[1]);
stream_int_report_error(&s->si[1]);
s->be->be_counters.failed_resp++;
if (srv)
@@ -1895,7 +1895,7 @@
/* shutdown(write) pending */
if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_OUT_EMPTY)) == (BF_SHUTW_NOW|BF_OUT_EMPTY)))
- s->req->cons->shutw(s->req->cons);
+ s->req->cons->sock.shutw(s->req->cons);
/* shutdown(write) done on server side, we must stop the client too */
if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTW &&
@@ -1904,7 +1904,7 @@
/* shutdown(read) pending */
if (unlikely((s->req->flags & (BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTR_NOW))
- s->req->prod->shutr(s->req->prod);
+ s->req->prod->sock.shutr(s->req->prod);
/* it's possible that an upper layer has requested a connection setup or abort.
* There are 2 situations where we decide to establish a new connection :
@@ -2026,7 +2026,7 @@
/* shutdown(write) pending */
if (unlikely((s->rep->flags & (BF_SHUTW|BF_OUT_EMPTY|BF_SHUTW_NOW)) == (BF_OUT_EMPTY|BF_SHUTW_NOW)))
- s->rep->cons->shutw(s->rep->cons);
+ s->rep->cons->sock.shutw(s->rep->cons);
/* shutdown(write) done on the client side, we must stop the server too */
if (unlikely((s->rep->flags & (BF_SHUTW|BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTW) &&
@@ -2035,7 +2035,7 @@
/* shutdown(read) pending */
if (unlikely((s->rep->flags & (BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTR_NOW))
- s->rep->prod->shutr(s->rep->prod);
+ s->rep->prod->sock.shutr(s->rep->prod);
if (s->req->prod->state == SI_ST_DIS || s->req->cons->state == SI_ST_DIS)
goto resync_stream_interface;
@@ -2086,10 +2086,10 @@
session_process_counters(s);
if (s->rep->cons->state == SI_ST_EST && s->rep->cons->target.type != TARG_TYPE_APPLET)
- s->rep->cons->update(s->rep->cons);
+ s->rep->cons->sock.update(s->rep->cons);
if (s->req->cons->state == SI_ST_EST && s->req->cons->target.type != TARG_TYPE_APPLET)
- s->req->cons->update(s->req->cons);
+ s->req->cons->sock.update(s->req->cons);
s->req->flags &= ~(BF_READ_NULL|BF_READ_PARTIAL|BF_WRITE_NULL|BF_WRITE_PARTIAL|BF_READ_ATTACHED);
s->rep->flags &= ~(BF_READ_NULL|BF_READ_PARTIAL|BF_WRITE_NULL|BF_WRITE_PARTIAL|BF_READ_ATTACHED);