MINOR: protocol: register the receiver's I/O handler and not the protocol's
Now we define a new sock_accept_iocb() for socket-based stream protocols
and use it as a wrapper for listener_accept() which now takes a listener
and not an FD anymore. This will allow the receiver's I/O cb to be
redefined during registration, and more specifically to get rid of the
hard-coded hacks in protocol_bind_all() made for syslog.
The previous ->accept() callback in the protocol was removed since it
doesn't have anything to do with accept() anymore but is more generic.
A few places where listener_accept() was compared against the FD's IO
callback for debugging purposes on the CLI were updated.
diff --git a/src/mworker.c b/src/mworker.c
index d45b357..690f3f0 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -334,7 +334,8 @@
/* This wrapper is called from the workers. It is registered instead of the
* normal listener_accept() so the worker can exit() when it detects that the
* master closed the IPC FD. If it's not a close, we just call the regular
- * listener_accept() function */
+ * listener_accept() function.
+ */
void mworker_accept_wrapper(int fd)
{
char c;
@@ -351,7 +352,10 @@
}
break;
} else if (ret > 0) {
- listener_accept(fd);
+ struct listener *l = fdtab[fd].owner;
+
+ if (l)
+ listener_accept(l);
return;
} else if (ret == 0) {
/* At this step the master is down before