]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/daemon.c
ITS#6255
[openldap] / servers / slapd / daemon.c
index 55681f47124044d5e29832d0cd16ac224f9bf808..03085182fb6aa6d3dd7ea8e4079487c8fe07ac2f 100644 (file)
@@ -957,7 +957,7 @@ slapd_set_write( ber_socket_t s, int wake )
                SLAP_SOCK_SET_WRITE( s );
                slap_daemon.sd_nwriters++;
        }
-       if (( wake & 2 ) && global_writetimeout ) {
+       if (( wake & 2 ) && global_writetimeout && !chk_writetime ) {
                chk_writetime = slap_get_time();
        }
 
@@ -1478,7 +1478,7 @@ slap_open_listener(
                 * create/unlink the socket; likely need exec perms to access
                 * the socket (ITS#4709) */
                {
-                       mode_t old_umask;
+                       mode_t old_umask = 0;
 
                        if ( (*sal)->sa_family == AF_LOCAL ) {
                                old_umask = umask( 0 );
@@ -1486,7 +1486,7 @@ slap_open_listener(
 #endif /* LDAP_PF_LOCAL */
                        rc = bind( s, *sal, addrlen );
 #ifdef LDAP_PF_LOCAL
-                       if ( (*sal)->sa_family == AF_LOCAL ) {
+                       if ( old_umask != 0 ) {
                                umask( old_umask );
                        }
                }
@@ -2177,7 +2177,7 @@ slapd_daemon_task(
                         */
                        if ( chk_writetime ) {
                                tv.tv_sec = global_writetimeout;
-                               tv.tv_usec = global_writetimeout;
+                               tv.tv_usec = 0;
                                if ( difftime( chk_writetime, now ) < 0 )
                                        check = 2;
                        } else {
@@ -2245,7 +2245,7 @@ slapd_daemon_task(
 
                nfds = SLAP_EVENT_MAX;
 
-               if ( global_idletimeout && slap_daemon.sd_nactives ) at = 1;
+               if (( chk_writetime || global_idletimeout ) && slap_daemon.sd_nactives ) at = 1;
 
                ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
 
@@ -2529,7 +2529,7 @@ slapd_daemon_task(
 #endif /* LDAP_DEBUG */
 
                for ( i = 0; i < ns; i++ ) {
-                       int rc = 1, fd, w = 0;
+                       int rc = 1, fd, w = 0, r = 0;
 
                        if ( SLAP_EVENT_IS_LISTENER( i ) ) {
                                rc = slap_listener_activate( SLAP_EVENT_LISTENER( i ) );
@@ -2569,24 +2569,25 @@ slapd_daemon_task(
                                        }
                                }
                                /* If event is a read */
-                               if ( SLAP_EVENT_IS_READ( i ) ) {
+                               if ( SLAP_EVENT_IS_READ( i ))
+                                       r = 1;
+                               if ( r || !w ) {
                                        Debug( LDAP_DEBUG_CONNS,
                                                "daemon: read active on %d\n",
                                                fd, 0, 0 );
 
-                                       SLAP_EVENT_CLR_READ( i );
-                                       connection_read_activate( fd );
-                               } else if ( !w ) {
-                                       Debug( LDAP_DEBUG_CONNS,
-                                               "daemon: hangup on %d\n", fd, 0, 0 );
-                                       if ( SLAP_SOCK_IS_ACTIVE( fd )) {
+                                       if ( r ) {
+                                               SLAP_EVENT_CLR_READ( i );
+                                       } else {
 #ifdef HAVE_EPOLL
                                                /* Don't keep reporting the hangup
                                                 */
-                                               SLAP_EPOLL_SOCK_SET( fd, EPOLLET );
+                                               if ( SLAP_SOCK_IS_ACTIVE( fd )) {
+                                                       SLAP_EPOLL_SOCK_SET( fd, EPOLLET );
+                                               }
 #endif
-                                               connection_hangup( fd );
                                        }
+                                       connection_read_activate( fd );
                                }
                        }
                }