From: Andre Noll Date: Sun, 6 Aug 2017 20:50:15 +0000 (+0200) Subject: server: Perform hostname lookup in client process. X-Git-Tag: v0.5.8~1 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=5924e7281692044588e6df713c5d6c694ddd69f1;p=paraslash.git server: Perform hostname lookup in client process. 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. --- diff --git a/server.c b/server.c index a023b152..af93941d 100644 --- 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);