Commit 65e66af7 authored by Niels Möller's avatar Niels Möller

mini-inetd: Clear O_NONBLOCK flag on accepted sockets. (from c3301261).

parent ecf340a3
2013-06-18 Niels Möller <nisse@lysator.liu.se>
From lsh-2.0.4 branch:
* src/testsuite/mini-inetd.c (main): Clear O_NONBLOCK flag on
accepted sockets.
* src/testsuite/tcpconnect.c: Include netinet/in.h.
(main): Set seen_remote_eof and seen_stdin_eof flags at EOF.
......
......@@ -291,6 +291,7 @@ main (int argc, char **argv)
if (FD_ISSET(fds[i], &wanted))
{
int conn;
int flags;
conn = accept(fds[i], NULL, NULL);
if (conn < 0)
......@@ -299,6 +300,16 @@ main (int argc, char **argv)
die("accept failed: %s\n", STRERROR(errno));
continue;
}
/* With traditional BSD behavior, the acccepted socket
inherits the O_NONBLOCK flag from the listening socket.
So clear it explicitly. */
flags = fcntl(conn, F_GETFL);
if (flags < 0)
werror("fcntl F_GETFL failed: %s\n", STRERROR(errno));
else if (fcntl(conn, F_SETFL, flags & ~O_NONBLOCK) < 0)
werror("fcntl F_SETFL failed: %s\n", STRERROR(errno));
start_service (conn, argv[1], argv + 2);
if (max_connections)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment