listen: don't make the server socket non-blocking
There is no point in making the server socket non-blocking. We call accept() only after select() has notified us about a new connection.
This commit is contained in:
@@ -67,11 +67,6 @@ static int establishListen(int pf, const struct sockaddr *addrp,
|
|||||||
if ((sock = socket(pf, SOCK_STREAM, 0)) < 0)
|
if ((sock = socket(pf, SOCK_STREAM, 0)) < 0)
|
||||||
g_error("socket < 0");
|
g_error("socket < 0");
|
||||||
|
|
||||||
if (set_nonblocking(sock) < 0) {
|
|
||||||
g_error("problems setting nonblocking on listen socket: %s",
|
|
||||||
strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&allowReuse,
|
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&allowReuse,
|
||||||
sizeof(allowReuse)) < 0) {
|
sizeof(allowReuse)) < 0) {
|
||||||
g_error("problems setsockopt'ing: %s", strerror(errno));
|
g_error("problems setsockopt'ing: %s", strerror(errno));
|
||||||
@@ -283,8 +278,7 @@ void getConnections(fd_set * fds)
|
|||||||
if ((fd = accept(listenSockets[i], &sockAddr, &socklen))
|
if ((fd = accept(listenSockets[i], &sockAddr, &socklen))
|
||||||
>= 0) {
|
>= 0) {
|
||||||
client_new(fd, &sockAddr, get_remote_uid(fd));
|
client_new(fd, &sockAddr, get_remote_uid(fd));
|
||||||
} else if (fd < 0
|
} else if (fd < 0 && errno != EINTR) {
|
||||||
&& (errno != EAGAIN && errno != EINTR)) {
|
|
||||||
g_warning("Problems accept()'ing");
|
g_warning("Problems accept()'ing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user