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.
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++;
/*
/* 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);