From abe1977070e2c71d82f473c6d3aa807b489c7fb0 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 22 Jun 2012 01:40:48 +0400 Subject: [PATCH] nbd-server: treat accept errors as non-fatal 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 --- nbd-server.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nbd-server.c b/nbd-server.c index 55b1347..82a05a3 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -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) { -- 2.34.1