From 25f7342809c210bc62bfe7823d0addaefef414d1 Mon Sep 17 00:00:00 2001 From: fche Date: Thu, 15 Mar 2001 00:27:05 +0000 Subject: [PATCH] * speedup 2001-03-14 Frank Ch. Eigler * socketio.cxx (asyncificate): Set TCP_NODELAY and SO_KEEPALIVE options. (init_handler): Don't bother with SO_KEEPALIVE here. * components.h: #include . --- sid/component/consoles/ChangeLog | 6 ++++++ sid/component/consoles/components.h | 1 + sid/component/consoles/socketio.cxx | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sid/component/consoles/ChangeLog b/sid/component/consoles/ChangeLog index db21bb2f6f..1c962ac2b4 100644 --- a/sid/component/consoles/ChangeLog +++ b/sid/component/consoles/ChangeLog @@ -1,3 +1,9 @@ +2001-03-14 Frank Ch. Eigler + + * socketio.cxx (asyncificate): Set TCP_NODELAY and SO_KEEPALIVE options. + (init_handler): Don't bother with SO_KEEPALIVE here. + * components.h: #include . + 2001-01-17 Jeff Johnston * stdio.cxx (stdioConsole::read): Change to read a reasonable size of diff --git a/sid/component/consoles/components.h b/sid/component/consoles/components.h index 1881d78325..69a640e106 100644 --- a/sid/component/consoles/components.h +++ b/sid/component/consoles/components.h @@ -36,6 +36,7 @@ extern "C" { #if HAVE_NETINET_IN_H #include #endif +#include #if HAVE_SYS_SOCKET_H #include #endif diff --git a/sid/component/consoles/socketio.cxx b/sid/component/consoles/socketio.cxx index 4179e3234b..ab9ba40f4d 100644 --- a/sid/component/consoles/socketio.cxx +++ b/sid/component/consoles/socketio.cxx @@ -188,8 +188,6 @@ socketio::socketio(bool s): int on = 1; on = 1; setsockopt (this->fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof (on)); - on = 1; - setsockopt (this->fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&on, sizeof (on)); // bind; even if INADDR_ANY & port 0 this->sock_name.sin_family = AF_INET; @@ -258,13 +256,24 @@ socketio::socketio(bool s): void socketio::asyncificate (int fd) { + // Disable transmit coalescing + int on = 1; + int rc = setsockopt (this->fd, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof (on)); + if (rc) + cerr << "setsockopt TCP_NODELAY error: " << std_error_string() << endl; + + on = 1; + rc = setsockopt (this->fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof (on)); + if (rc) + cerr << "setsockopt SO_KEEPALIVE error: " << std_error_string() << endl; + // Make this file descriptor nonblocking. // Don't make it O_ASYNC though - we don't care about SIGIO. // POSIX way int flags = fcntl (fd, F_GETFL, 0); flags |= O_NONBLOCK; - int rc = fcntl (fd, F_SETFL, flags); + rc = fcntl (fd, F_SETFL, flags); if (rc == -1) cerr << "fcntl error: " << std_error_string() << endl; -- 2.11.0