]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Perform hostname lookup in client process.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2017 20:50:15 +0000 (22:50 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 8 Aug 2017 10:36:44 +0000 (12:36 +0200)
When a connection arrives at the TCP command socket, the server process
looks up the remote name before it forks the child process. This is bad
because the server process can not afford to sleep, but name lookup may
take some time, for example if a DNS server is currently unavailable.

We may as well look up the hostname after the fork in the child
process, where blocking operations are not a problem.

server.c

index a023b1526931c1eeeb3fcec7be3a6b6c72662c69..af93941dd6dba2a56fc2cb63d23162f9355c46fb 100644 (file)
--- a/server.c
+++ b/server.c
@@ -331,8 +331,6 @@ static int command_post_select(struct sched *s, void *context)
        ret = para_accept(sct->listen_fd, &s->rfds, NULL, 0, &new_fd);
        if (ret <= 0)
                goto out;
-       peer_name = remote_name(new_fd);
-       PARA_INFO_LOG("got connection from %s, forking\n", peer_name);
        mmd->num_connects++;
        mmd->active_connections++;
        /*
@@ -358,6 +356,8 @@ static int command_post_select(struct sched *s, void *context)
                /* parent keeps accepting connections */
                return 0;
        }
+       peer_name = remote_name(new_fd);
+       PARA_INFO_LOG("accepted connection from %s\n", peer_name);
        /* mmd might already have changed at this point */
        free(chunk_table);
        alarm(ALARM_TIMEOUT);