Browse Source

[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 6 years ago
parent
commit
1645e3435f
1 changed files with 1 additions and 1 deletions
  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;
     }