nbd-server: treat accept errors as non-fatal
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Jun 2012 21:40:48 +0000 (01:40 +0400)
committerWouter Verhelst <w@uter.be>
Sat, 23 Jun 2012 23:38:34 +0000 (01:38 +0200)
In most cases, an error returned by accept system call is a network
error, which should not terminate the whole nbd-server.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
nbd-server.c

index 55b13470759844cbcd4a73ef4b0893f392cb8833..82a05a3efae1c68c8166a017ecea06b326284b52 100644 (file)
@@ -2204,8 +2204,10 @@ int serveloop(GArray* servers) {
 
                        DEBUG("accept, ");
                        if(modernsock >= 0 && FD_ISSET(modernsock, &rset)) {
-                               if((net=accept(modernsock, (struct sockaddr *) &addrin, &addrinlen)) < 0)
-                                       err("accept: %m");
+                               if((net=accept(modernsock, (struct sockaddr *) &addrin, &addrinlen)) < 0) {
+                                       err_nonfatal("accept: %m");
+                                       continue;
+                               }
                                client = negotiate(net, NULL, servers, NEG_INIT | NEG_MODERN);
                                if(!client) {
                                        err_nonfatal("negotiation failed");
@@ -2217,8 +2219,10 @@ int serveloop(GArray* servers) {
                        for(i=0; i < servers->len && net < 0; i++) {
                                serve=&(g_array_index(servers, SERVER, i));
                                if(FD_ISSET(serve->socket, &rset)) {
-                                       if ((net=accept(serve->socket, (struct sockaddr *) &addrin, &addrinlen)) < 0)
-                                               err("accept: %m");
+                                       if ((net=accept(serve->socket, (struct sockaddr *) &addrin, &addrinlen)) < 0) {
+                                               err_nonfatal("accept: %m");
+                                               continue;
+                                       }
                                }
                        }
                        if(net >= 0) {