diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index 499609dc0..5c9793b58 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -104,6 +104,9 @@ struct protocol { int (*rx_resume)(struct receiver *rx); /* try to resume a temporarily suspended receiver */ int (*rx_listening)(const struct receiver *rx); /* is the receiver listening ? 0=no, >0=OK, <0=unrecoverable */ + /* default I/O handler */ + void (*default_iocb)(int fd); /* generic I/O handler (typically accept callback) */ + /* functions acting on connections */ void (*accept)(int fd); /* generic accept function */ int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */ diff --git a/include/haproxy/receiver-t.h b/include/haproxy/receiver-t.h index 6f267ba12..5b17211c4 100644 --- a/include/haproxy/receiver-t.h +++ b/include/haproxy/receiver-t.h @@ -59,6 +59,7 @@ struct receiver { unsigned int flags; /* receiver options (RX_F_*) */ struct protocol *proto; /* protocol this receiver belongs to */ void *owner; /* receiver's owner (usually a listener) */ + void (*iocb)(int fd); /* generic I/O handler (typically accept callback) */ struct rx_settings *settings; /* points to the settings used by this receiver */ struct list proto_list; /* list in the protocol header */ /* warning: this struct is huge, keep it at the bottom */ diff --git a/src/listener.c b/src/listener.c index baf1844e4..1cad1bb10 100644 --- a/src/listener.c +++ b/src/listener.c @@ -588,7 +588,8 @@ void unbind_listener(struct listener *listener) /* creates one or multiple listeners for bind_conf on sockaddr on port * range to , and possibly attached to fd (or -1 for auto * allocation). The address family is taken from ss->ss_family, and the protocol - * passed in must be usable on this family. The number of jobs and + * passed in must be usable on this family. The protocol's default iocb + * is automatically preset as the receivers' iocb. The number of jobs and * listeners is automatically increased by the number of listeners created. It * returns non-zero on success, zero on error with the error message set in . */ @@ -610,6 +611,7 @@ int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss, l->bind_conf = bc; l->rx.settings = &bc->settings; l->rx.owner = l; + l->rx.iocb = proto->default_iocb; l->rx.fd = fd; memcpy(&l->rx.addr, ss, sizeof(*ss)); MT_LIST_INIT(&l->wait_queue);