Explorar o código

[LibOS] Allow repeated listen() on the same socket

Typically, listen() is called only once by the application, to mark the
socket as passive for listening for client connections. Thus, LibOS had
a state machine that forbade performing repeated listen() syscalls on
the same socket. However, at least Nginx issues repeated listen's to
adjust the backlog parameter. This commit allows such corner cases.
Dmitrii Kuvaiskii %!s(int64=6) %!d(string=hai) anos
pai
achega
1645e3435f
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      LibOS/shim/src/sys/shim_socket.c

+ 1 - 1
LibOS/shim/src/sys/shim_socket.c

@@ -630,7 +630,7 @@ int shim_do_listen(int sockfd, int backlog) {
     enum shim_sock_state state = sock->sock_state;
     int ret                    = -EINVAL;
 
-    if (state != SOCK_BOUND) {
+    if (state != SOCK_BOUND && state != SOCK_LISTENED) {
         debug("shim_listen: listen on unbound socket\n");
         goto out;
     }