Signed-off-by: Tuomas Räsänen <[email protected]>
---
 nbd-server.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/nbd-server.c b/nbd-server.c
index ac5b8b7..b2134c4 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -2354,12 +2354,17 @@ handler_err:
 }
 
 static void
-handle_oldstyle_connection(GArray *servers, int net, SERVER *serve)
+handle_oldstyle_connection(GArray *servers, int sock, SERVER *serve)
 {
+       int net;
        CLIENT *client = NULL;
        int sock_flags_old;
        int sock_flags_new;
 
+       net = socket_accept(sock);
+       if (net < 0)
+               return;
+
        if(serve->max_connections > 0 &&
           g_hash_table_size(children) >= serve->max_connections) {
                msg(LOG_INFO, "Max connections reached");
@@ -2517,8 +2522,6 @@ out:
  * Loop through the available servers, and serve them. Never returns.
  **/
 void serveloop(GArray* servers) {
-       struct sockaddr_storage addrin;
-       socklen_t addrinlen=sizeof(addrin);
        int i;
        int max;
        int sock;
@@ -2592,7 +2595,6 @@ void serveloop(GArray* servers) {
                                handle_modern_connection(servers, sock);
                        }
                        for(i=0; i < servers->len; i++) {
-                               int net;
                                SERVER *serve;
 
                                serve=&(g_array_index(servers, SERVER, i));
@@ -2600,11 +2602,7 @@ void serveloop(GArray* servers) {
                                        continue;
                                }
                                if(FD_ISSET(serve->socket, &rset)) {
-                                       if ((net=accept(serve->socket, (struct 
sockaddr *) &addrin, &addrinlen)) < 0) {
-                                               err_nonfatal("accept: %m");
-                                               continue;
-                                       }
-                                       handle_oldstyle_connection(servers, 
net, serve);
+                                       handle_oldstyle_connection(servers, 
serve->socket, serve);
                                }
                        }
                }
-- 
1.7.10.4


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Nbd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nbd-general

Reply via email to