changeset 1948:6b80900ddc66

HTTP: continue after accept() failure
author Adam Chlipala <adam@chlipala.net>
date Mon, 30 Dec 2013 11:01:42 -0500
parents 619191c71abb
children d7bec4e63415
files src/c/http.c
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/http.c	Sun Dec 29 13:18:50 2013 -0500
+++ b/src/c/http.c	Mon Dec 30 11:01:42 2013 -0500
@@ -430,19 +430,19 @@
     int new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
 
     if (new_fd < 0) {
-      fprintf(stderr, "Socket accept failed\n");
-      return 1;
+      if (!quiet)
+        fprintf(stderr, "Socket accept failed\n");
+    } else {
+      if (!quiet)
+        printf("Accepted connection.\n");
+
+      if (keepalive) {
+        int flag = 1; 
+        setsockopt(new_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+      }
+
+      uw_enqueue(new_fd);
     }
-
-    if (!quiet)
-      printf("Accepted connection.\n");
-
-    if (keepalive) {
-      int flag = 1; 
-      setsockopt(new_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
-    }
-
-    uw_enqueue(new_fd);
   }
 }