]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG/MEDIUM: move protocol->{read,write} to sock_ops
authorWilly Tarreau <w@1wt.eu>
Mon, 7 May 2012 15:01:39 +0000 (17:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 19:28:14 +0000 (21:28 +0200)
The protocol must not set the read and write callbacks, they're specific
to the socket layer. Move them to sock_ops instead.

include/types/protocols.h
src/proto_tcp.c
src/proto_uxst.c
src/session.c
src/stream_interface.c
src/stream_sock.c

index eba4874b520f0cf1004c20ff9220f0359000f104..104cee56ff8ddc5282d6198bef6fa71ec900b676 100644 (file)
@@ -149,8 +149,6 @@ struct protocol {
        socklen_t sock_addrlen;                         /* socket address length, used by bind() */
        int l3_addrlen;                                 /* layer3 address length, used by hashes */
        int (*accept)(int fd);                          /* generic accept function */
-       int (*read)(int fd);                            /* generic read function */
-       int (*write)(int fd);                           /* generic write function */
        int (*bind)(struct listener *l, char *errmsg, int errlen); /* bind a listener */
        int (*bind_all)(struct protocol *proto, char *errmsg, int errlen); /* bind all unbound listeners */
        int (*unbind_all)(struct protocol *proto);      /* unbind all bound listeners */
index 1f0d6dce77a5499a9dd2ac8c84d05c10cdb083a4..f709e736557eb9d0d650611e7c5db15b9dbbf66c 100644 (file)
@@ -70,8 +70,6 @@ static struct protocol proto_tcpv4 = {
        .sock_addrlen = sizeof(struct sockaddr_in),
        .l3_addrlen = 32/8,
        .accept = &stream_sock_accept,
-       .read = &stream_sock_read,
-       .write = &stream_sock_write,
        .bind = tcp_bind_listener,
        .bind_all = tcp_bind_listeners,
        .unbind_all = unbind_all_listeners,
@@ -90,8 +88,6 @@ static struct protocol proto_tcpv6 = {
        .sock_addrlen = sizeof(struct sockaddr_in6),
        .l3_addrlen = 128/8,
        .accept = &stream_sock_accept,
-       .read = &stream_sock_read,
-       .write = &stream_sock_write,
        .bind = tcp_bind_listener,
        .bind_all = tcp_bind_listeners,
        .unbind_all = unbind_all_listeners,
@@ -446,9 +442,9 @@ int tcp_connect_server(struct stream_interface *si)
        fdtab[fd].owner = si;
        fdtab[fd].state = FD_STCONN; /* connection in progress */
        fdtab[fd].flags = FD_FL_TCP | FD_FL_TCP_NODELAY;
-       fdtab[fd].cb[DIR_RD].f = &stream_sock_read;
+       fdtab[fd].cb[DIR_RD].f = si->sock.read;
        fdtab[fd].cb[DIR_RD].b = si->ib;
-       fdtab[fd].cb[DIR_WR].f = &stream_sock_write;
+       fdtab[fd].cb[DIR_WR].f = si->sock.write;
        fdtab[fd].cb[DIR_WR].b = si->ob;
 
        fdinfo[fd].peeraddr = (struct sockaddr *)&si->addr.to;
index 6fb7264d52c626f636114e8347f51c39445853fc..2140ae6cae18da79a70bf4c01bcfa4faf77fc436 100644 (file)
@@ -56,8 +56,6 @@ static struct protocol proto_unix = {
        .sock_addrlen = sizeof(struct sockaddr_un),
        .l3_addrlen = sizeof(((struct sockaddr_un*)0)->sun_path),/* path len */
        .accept = &stream_sock_accept,
-       .read = &stream_sock_read,
-       .write = &stream_sock_write,
        .bind = uxst_bind_listener,
        .bind_all = uxst_bind_listeners,
        .unbind_all = uxst_unbind_listeners,
index fabba1f2016590875164bd26234d0961602c8e0d..96b93b96241c2295a15b3b7022779fc70e322c65 100644 (file)
@@ -285,9 +285,9 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        fdtab[cfd].owner = &s->si[0];
        fdtab[cfd].state = FD_STREADY;
        fdtab[cfd].flags = 0;
-       fdtab[cfd].cb[DIR_RD].f = l->proto->read;
+       fdtab[cfd].cb[DIR_RD].f = s->si[0].sock.read;
        fdtab[cfd].cb[DIR_RD].b = s->req;
-       fdtab[cfd].cb[DIR_WR].f = l->proto->write;
+       fdtab[cfd].cb[DIR_WR].f = s->si[0].sock.write;
        fdtab[cfd].cb[DIR_WR].b = s->rep;
        fdinfo[cfd].peeraddr = (struct sockaddr *)&s->si[0].addr.from;
        fdinfo[cfd].peerlen  = sizeof(s->si[0].addr.from);
index 209762382ee2e31df20d15c2041a5b72694ce27f..b6188d0b790c6c1f2c1315c4f2ea23d5823f6f45 100644 (file)
@@ -313,6 +313,8 @@ struct task *stream_int_register_handler(struct stream_interface *si, struct si_
        si->sock.shutw   = stream_int_shutw;
        si->sock.chk_rcv = stream_int_chk_rcv;
        si->sock.chk_snd = stream_int_chk_snd;
+       si->sock.read    = NULL;
+       si->sock.write   = NULL;
        si->connect = NULL;
        set_target_applet(&si->target, app);
        si->applet.state = 0;
@@ -340,6 +342,8 @@ struct task *stream_int_register_handler_task(struct stream_interface *si,
        si->sock.shutw   = stream_int_shutw;
        si->sock.chk_rcv = stream_int_chk_rcv;
        si->sock.chk_snd = stream_int_chk_snd;
+       si->sock.read    = NULL;
+       si->sock.write   = NULL;
        si->connect = NULL;
        clear_target(&si->target);
        si->release   = NULL;
index 3862ac8630480552bf220f993eba62d962937ae4..a77ad392863221887cefa5cc006f4d51c0d2048d 100644 (file)
@@ -1305,6 +1305,8 @@ void stream_sock_prepare_interface(struct stream_interface *si)
        si->sock.shutw   = stream_sock_shutw;
        si->sock.chk_rcv = stream_sock_chk_rcv;
        si->sock.chk_snd = stream_sock_chk_snd;
+       si->sock.read    = stream_sock_read;
+       si->sock.write   = stream_sock_write;
 }