tcp_listen: Missing register_poll_fd
Bug fix: tcpx_listen() needs to invoke the socket's register_poll_fd()
callback so that platforms can add the socket to their collection of
sockets-of-interest (primarily Windows, also platforms that use select()
and not poll()).
Same for udpx_listen(). Register the created socket!
For Windows, host forwarding "now works gooder!"
The socket is eventually unregistered via the two use cases in which
tcpx_listen() is used:
- slirp_add_hostfwd, slirp_add_hostxfwd: The corresponding "remove"
functions (slirp_remove_hostfwd, slirp_remove_hostxfwd) invoke
unregister_poll_fd().
- TCP emulation (tcp_emu() in tcp_subr.c): All calls to tcp_listen() set
the SS_FACCEPTONCE flag, making the accept() a one-shot event. By
carefully examining tcp_subr.c, lines 523-531, one sees that
tcp_connect() unregisters the one-shot accept().
QED.
diff --git a/src/socket.c b/src/socket.c
index 51a1364..c426be9 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -889,6 +889,8 @@
sotranslate_accept(so);
so->s = s;
+ so->slirp->cb->register_poll_fd(so->s, so->slirp->opaque);
+
return so;
}
diff --git a/src/udp.c b/src/udp.c
index 2965b18..f5ca294 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -404,6 +404,7 @@
so->so_expire = 0;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_ISFCONNECTED | flags;
+ so->slirp->cb->register_poll_fd(so->s, so->slirp->opaque);
return so;
}