telnetd: set SO_KEEPALIVE, users report it's useful. +20 bytes.

This commit is contained in:
Denis Vlasenko 2008-11-09 00:44:40 +00:00
parent 3fa36e2350
commit 6d0443557c

View File

@ -182,6 +182,8 @@ make_new_session(
ndelay_on(fd); ndelay_on(fd);
#if ENABLE_FEATURE_TELNETD_STANDALONE #if ENABLE_FEATURE_TELNETD_STANDALONE
ts->sockfd_read = sock; ts->sockfd_read = sock;
/* SO_KEEPALIVE by popular demand */
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
ndelay_on(sock); ndelay_on(sock);
if (!sock) { /* We are called with fd 0 - we are in inetd mode */ if (!sock) { /* We are called with fd 0 - we are in inetd mode */
sock++; /* so use fd 1 for output */ sock++; /* so use fd 1 for output */
@ -191,6 +193,8 @@ make_new_session(
if (sock > maxfd) if (sock > maxfd)
maxfd = sock; maxfd = sock;
#else #else
/* SO_KEEPALIVE by popular demand */
setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
/* ts->sockfd_read = 0; - done by xzalloc */ /* ts->sockfd_read = 0; - done by xzalloc */
ts->sockfd_write = 1; ts->sockfd_write = 1;
ndelay_on(0); ndelay_on(0);