]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/daemon.c
- setup framework for monitoring of back-bdb/back-hdb stuff in their
[openldap] / servers / slapd / daemon.c
index 97fd9741b33ad862a9e28342952b2d039366ed27..31596c4846bdc572bed4d7016f02fc0198375154 100644 (file)
@@ -235,6 +235,16 @@ static struct slap_daemon {
        for (i=0; i<dtblsize; i++) slap_daemon.sd_index[i] = -1; \
 } while (0)
 
+#define SLAP_SOCK_SET_DESTROY do { \
+       if ( slap_daemon.sd_epolls != NULL ) { \
+               ch_free( slap_daemon.sd_epolls ); \
+               slap_daemon.sd_epolls = NULL; \
+               ch_free( slap_daemon.sd_index ); \
+               slap_daemon.sd_index = NULL; \
+               close( slap_daemon.sd_epfd ); \
+       } \
+} while ( 0 )
+
 # define SLAP_EVENT_DECL struct epoll_event *revents
 
 # define SLAP_EVENT_INIT do { \
@@ -275,6 +285,8 @@ static struct slap_daemon {
        FD_ZERO(&slap_daemon.sd_writers); \
 } while (0)
 
+#define                SLAP_SOCK_SET_DESTROY
+
 # define SLAP_SOCK_IS_ACTIVE(fd)       FD_ISSET((fd), &slap_daemon.sd_actives)
 # define SLAP_SOCK_IS_READ(fd)         FD_ISSET((fd), &slap_daemon.sd_readers)
 # define SLAP_SOCK_IS_WRITE(fd)                FD_ISSET((fd), &slap_daemon.sd_writers)
@@ -339,7 +351,7 @@ static struct slap_daemon {
 static char** slapd_srvurls = NULL;
 static SLPHandle slapd_hslp = 0;
 int slapd_register_slp = 0;
-char *slapd_slp_attrs = NULL;
+const char *slapd_slp_attrs = NULL;
 
 static SLPError slapd_slp_cookie;
 
@@ -501,6 +513,7 @@ void slapd_sd_unlock()
  */
 void slapd_remove(
        ber_socket_t s,
+       Sockbuf *sb,
        int wasactive,
        int wake,
        int locked )
@@ -527,6 +540,9 @@ void slapd_remove(
 
        SLAP_DEL_SOCK(s);
 
+       if ( sb )
+               ber_sockbuf_free(sb);
+
        /* If we ran out of file descriptors, we dropped a listener from
         * the select() loop. Now that we're removing a session from our
         * control, we can try to resume a dropped listener to use.
@@ -1262,7 +1278,7 @@ close_listeners(
                Listener *lr = slap_listeners[l];
 
                if ( lr->sl_sd != AC_SOCKET_INVALID ) {
-                       if ( remove ) slapd_remove( lr->sl_sd, 0, 0, 0 );
+                       if ( remove ) slapd_remove( lr->sl_sd, NULL, 0, 0, 0 );
 
 #ifdef LDAP_PF_LOCAL
                        if ( lr->sl_sa.sa_addr.sa_family == AF_LOCAL ) {
@@ -2094,7 +2110,7 @@ slapd_daemon_task(
 #endif
 
                for (i=0; i<ns; i++) {
-                       int rc = 1, fd, waswrite = 0;
+                       int rc = 1, fd;
 
                        if ( SLAP_EVENT_IS_LISTENER(i) ) {
 #ifdef SLAP_LIGHTWEIGHT_DISPATCHER
@@ -2124,7 +2140,7 @@ slapd_daemon_task(
                                                "daemon: write active on %d\n",
                                                fd, 0, 0 );
 
-                                       waswrite = 1;
+                                       SLAP_EVENT_CLR_WRITE( i );
 
                                        /*
                                         * NOTE: it is possible that the connection was closed
@@ -2136,12 +2152,13 @@ slapd_daemon_task(
                                                continue;
                                        }
                                }
-                               /* If event is a read or an error */
-                               if( SLAP_EVENT_IS_READ( i ) || !waswrite ) {
+                               /* If event is a read */
+                               if( SLAP_EVENT_IS_READ( i )) {
                                        Debug( LDAP_DEBUG_CONNS,
                                                "daemon: read active on %d\n",
                                                fd, 0, 0 );
 
+                                       SLAP_EVENT_CLR_READ( i );
 #ifdef SLAP_LIGHTWEIGHT_DISPATCHER
                                        connection_read_activate( fd );
 #else
@@ -2153,6 +2170,9 @@ slapd_daemon_task(
                                         */
                                        connection_read( fd );
 #endif
+                               } else {
+                                       Debug( LDAP_DEBUG_CONNS,
+                                               "daemon: hangup on %d\n", fd, 0, 0 );
                                }
                        }
                }
@@ -2311,6 +2331,8 @@ static int sockdestroy(void)
 #if defined( HAVE_WINSOCK2 ) || defined( HAVE_WINSOCK )
        WSACleanup();
 #endif
+       SLAP_SOCK_SET_DESTROY;
+
        return 0;
 }