]> git.sur5r.net Git - openldap/commitdiff
ITS#6111
authorQuanah Gibson-Mount <quanah@openldap.org>
Fri, 15 May 2009 00:02:49 +0000 (00:02 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Fri, 15 May 2009 00:02:49 +0000 (00:02 +0000)
CHANGES
servers/slapd/connection.c
servers/slapd/proto-slap.h
servers/slapd/result.c

diff --git a/CHANGES b/CHANGES
index 817aa36e5a00267dc0e9424d877179c9e672b8a3..a9819d7f9aad315c1c22837276d586229b83b3f7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,7 @@ OpenLDAP 2.4.17 Engineering
        Fixed libldap tls NULL error messages (ITS#6079)
        Fixed liblutil opendir/closedir on windows (ITS#6041)
        Fixed liblutil for _GNU_SOURCE (ITS#5464,ITS#5666)
+       Fixed slapd assert with closing connections (ITS#6111)
        Fixed slapd cert validation (ITS#6098)
        Fixed slapd errno handling (ITS#6037)
        Fixed slapd global alloc handling (ITS#6054)
index ebfd5d4ee1fafeff8e48433dcbc6d0b679d0b617..7cfcd7b927cfad80ea4e4ba20fb26fbe1f2a5bb7 100644 (file)
@@ -53,18 +53,22 @@ static unsigned long conn_nextid = 0;
 static const char conn_lost_str[] = "connection lost";
 
 /* structure state (protected by connections_mutex) */
-#define SLAP_C_UNINITIALIZED   0x00    /* MUST BE ZERO (0) */
-#define SLAP_C_UNUSED                  0x01
-#define SLAP_C_USED                            0x02
-#define        SLAP_C_PENDING                  0x03
+enum sc_struct_state {
+       SLAP_C_UNINITIALIZED = 0,       /* MUST BE ZERO (0) */
+       SLAP_C_UNUSED,
+       SLAP_C_USED,
+       SLAP_C_PENDING
+};
 
 /* connection state (protected by c_mutex ) */
-#define SLAP_C_INVALID                 0x00    /* MUST BE ZERO (0) */
-#define SLAP_C_INACTIVE                        0x01    /* zero threads */
-#define SLAP_C_ACTIVE                  0x02    /* one or more threads */
-#define SLAP_C_BINDING                 0x03    /* binding */
-#define SLAP_C_CLOSING                 0x04    /* closing */
-#define SLAP_C_CLIENT                  0x05    /* outbound client conn */
+enum sc_conn_state {
+       SLAP_C_INVALID = 0,             /* MUST BE ZERO (0) */
+       SLAP_C_INACTIVE,                /* zero threads */
+       SLAP_C_CLOSING,                 /* closing */
+       SLAP_C_ACTIVE,                  /* one or more threads */
+       SLAP_C_BINDING,                 /* binding */
+       SLAP_C_CLIENT                   /* outbound client conn */
+};
 
 const char *
 connection_state2str( int state )
@@ -72,9 +76,9 @@ connection_state2str( int state )
        switch( state ) {
        case SLAP_C_INVALID:    return "!";
        case SLAP_C_INACTIVE:   return "|";
+       case SLAP_C_CLOSING:    return "C";
        case SLAP_C_ACTIVE:             return "";
        case SLAP_C_BINDING:    return "B";
-       case SLAP_C_CLOSING:    return "C";
        case SLAP_C_CLIENT:             return "L";
        }
 
@@ -677,19 +681,15 @@ connection_destroy( Connection *c )
        }
 }
 
-int connection_state_closing( Connection *c )
+int connection_valid( Connection *c )
 {
        /* c_mutex must be locked by caller */
 
-       int state;
        assert( c != NULL );
-       assert( c->c_struct_state == SLAP_C_USED );
-
-       state = c->c_conn_state;
-
-       assert( state != SLAP_C_INVALID );
 
-       return state == SLAP_C_CLOSING;
+       return c->c_struct_state == SLAP_C_USED &&
+               c->c_conn_state >= SLAP_C_ACTIVE &&
+               c->c_conn_state <= SLAP_C_CLIENT;
 }
 
 static void connection_abandon( Connection *c )
index 9ed21bb3714cc7674df2607080ea56618535f65c..e52288cc675491cd30923256a97ef897437ffbb0 100644 (file)
@@ -759,7 +759,7 @@ LDAP_SLAPD_F (Connection *) connection_init LDAP_P((
 LDAP_SLAPD_F (void) connection_closing LDAP_P((
        Connection *c, const char *why ));
 LDAP_SLAPD_F (void) connection_hangup LDAP_P(( ber_socket_t fd ));
-LDAP_SLAPD_F (int) connection_state_closing LDAP_P(( Connection *c ));
+LDAP_SLAPD_F (int) connection_valid LDAP_P(( Connection *c ));
 LDAP_SLAPD_F (const char *) connection_state2str LDAP_P(( int state ))
        LDAP_GCCATTR((const));
 
index 4f2a7f17b12e5ea3f58ace77df8ef316ea7cf269..406b7d6347ec54cc9d3dc7ce98f1e04bb210b495 100644 (file)
@@ -145,7 +145,7 @@ static long send_ldap_ber(
 
        /* write only one pdu at a time - wait til it's our turn */
        ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
-       if (( op->o_abandon && !op->o_cancel ) || connection_state_closing( conn )) {
+       if (( op->o_abandon && !op->o_cancel ) || !connection_valid( conn )) {
                ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
                return 0;
        }