MEDIUM: protocol: do not call proto->bind() anymore from bind_listener()
All protocol's listeners now only take care of themselves and not of
the receiver anymore since that's already being done in proto_bind_all().
Now it finally becomes obvious that UDP doesn't need a listener, as the
only thing it does is to set the listener's state to LI_LISTEN!
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 57ccfed..4af22e5 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -561,6 +561,8 @@
socklen_t ready_len;
char *msg = NULL;
+ err = ERR_NONE;
+
/* ensure we never return garbage */
if (errlen)
*errmsg = 0;
@@ -568,11 +570,9 @@
if (listener->state != LI_ASSIGNED)
return ERR_NONE; /* already bound */
- err = sock_inet_bind_receiver(&listener->rx, listener->rx.proto->accept, &msg);
- if (err != ERR_NONE) {
- snprintf(errmsg, errlen, "%s", msg);
- free(msg); msg = NULL;
- return err;
+ if (!(listener->rx.flags & RX_F_BOUND)) {
+ msg = "receiving socket not bound";
+ goto tcp_return;
}
fd = listener->rx.fd;
@@ -691,6 +691,7 @@
tcp_close_return:
close(fd);
+ tcp_return:
if (msg && errlen) {
char pn[INET6_ADDRSTRLEN];