From bbae507a8f650ed481af8ea1183c11214acea581 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 21 Sep 2000 19:08:17 +0000 Subject: [PATCH] Set TCP_NODELAY and SO_KEEPALIVE after every accept() as some accept() implementations do not create new socket with all properties of listening socket. --- servers/slapd/daemon.c | 50 ++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 14f3f168d9..57c93e5e61 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -402,30 +402,6 @@ static Listener * open_listener( const char* url ) (long) l.sl_sd, err, sock_errstr(err) ); } #endif -#ifdef SO_KEEPALIVE - /* enable keep alives */ - tmp = 1; - rc = setsockopt( l.sl_sd, SOL_SOCKET, SO_KEEPALIVE, - (char *) &tmp, sizeof(tmp) ); - if ( rc == AC_SOCKET_ERROR ) { - int err = sock_errno(); - Debug( LDAP_DEBUG_ANY, - "slapd(%ld): setsockopt(SO_KEEPALIVE) failed errno=%d (%s)\n", - (long) l.sl_sd, err, sock_errstr(err) ); - } -#endif -#ifdef TCP_NODELAY - /* enable no delay */ - tmp = 1; - rc = setsockopt( l.sl_sd, IPPROTO_TCP, TCP_NODELAY, - (char *)&tmp, sizeof(tmp) ); - if ( rc == AC_SOCKET_ERROR ) { - int err = sock_errno(); - Debug( LDAP_DEBUG_ANY, - "slapd(%ld): setsockopt(TCP_NODELAY) failed errno=%d (%s)\n", - (long) l.sl_sd, err, sock_errstr(err) ); - } -#endif #ifdef HAVE_GETADDRINFO } /* sai->ai_family != AF_LOCAL */ @@ -666,6 +642,7 @@ slapd_daemon_task( void *ptr ) { + int rc, tmp; int l; time_t last_idle_check = slap_get_time(); time( &starttime ); @@ -881,6 +858,31 @@ slapd_daemon_task( } #endif +#ifdef SO_KEEPALIVE + /* enable keep alives */ + rc = setsockopt( s, SOL_SOCKET, SO_KEEPALIVE, + (char *) &tmp, sizeof(tmp) ); + if ( rc == AC_SOCKET_ERROR ) { + int err = sock_errno(); + Debug( LDAP_DEBUG_ANY, + "slapd(%ld): setsockopt(SO_KEEPALIVE) failed " + "errno=%d (%s)\n", (long) s, err, sock_errstr(err) ); + } +#endif +#ifdef TCP_NODELAY + /* enable no delay */ + tmp = 1; + rc = setsockopt( s, IPPROTO_TCP, TCP_NODELAY, + (char *)&tmp, sizeof(tmp) ); + if ( rc == AC_SOCKET_ERROR ) { + int err = sock_errno(); + Debug( LDAP_DEBUG_ANY, + "slapd(%ld): setsockopt(TCP_NODELAY) failed " + "errno=%d (%s)\n", (long) s, err, sock_errstr(err) ); + } +#endif + + #ifdef LDAP_DEBUG ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); -- 2.39.5