mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-01 22:48:25 +00:00
REORG/MEDIUM: move protocol->{read,write} to sock_ops
The protocol must not set the read and write callbacks, they're specific to the socket layer. Move them to sock_ops instead.
This commit is contained in:
parent
060781fb4a
commit
1b79bdee26
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user