]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/connection.c
update for new backend types
[openldap] / servers / slapd / connection.c
index c6ef075ac06d0d7bf8e747c7180a05c22d6a8026..56c02c2f7a199bf076fc1c228ccc7d21b221a763 100644 (file)
@@ -26,7 +26,9 @@
 #include "portable.h"
 
 #include <stdio.h>
+#ifdef HAVE_LIMITS_H
 #include <limits.h>
+#endif
 
 #include <ac/socket.h>
 #include <ac/errno.h>
@@ -596,21 +598,21 @@ void connection2anonymous( Connection *c )
                ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
        }
 
-       if(c->c_authmech.bv_val != NULL ) {
-               free(c->c_authmech.bv_val);
+       if ( !BER_BVISNULL( &c->c_authmech ) ) {
+               ch_free(c->c_authmech.bv_val);
        }
        BER_BVZERO( &c->c_authmech );
 
-       if(c->c_dn.bv_val != NULL) {
-               free(c->c_dn.bv_val);
+       if ( !BER_BVISNULL( &c->c_dn ) ) {
+               ch_free(c->c_dn.bv_val);
        }
        BER_BVZERO( &c->c_dn );
-       if(c->c_ndn.bv_val != NULL) {
-               free(c->c_ndn.bv_val);
+       if ( !BER_BVISNULL( &c->c_ndn ) ) {
+               ch_free(c->c_ndn.bv_val);
        }
        BER_BVZERO( &c->c_ndn );
-       if(c->c_sasl_authz_dn.bv_val != NULL) {
-               free(c->c_sasl_authz_dn.bv_val);
+       if ( !BER_BVISNULL( &c->c_sasl_authz_dn ) ) {
+               ber_memfree_x( c->c_sasl_authz_dn.bv_val, NULL );
        }
        BER_BVZERO( &c->c_sasl_authz_dn );
 
@@ -765,7 +767,12 @@ void connection_closing( Connection *c )
 
                /* wake write blocked operations */
                slapd_clr_write( sd, 1 );
-               ldap_pvt_thread_cond_signal( &c->c_write_cv );
+               if ( c->c_writewaiter ) {
+                       ldap_pvt_thread_cond_signal( &c->c_write_cv );
+                       ldap_pvt_thread_mutex_unlock( &c->c_mutex );
+                       ldap_pvt_thread_yield();
+                       ldap_pvt_thread_mutex_lock( &c->c_mutex );
+               }
        }
 }
 
@@ -1467,16 +1474,32 @@ connection_input(
         * already pending ops, let them go first.  Abandon operations
         * get exceptions to some, but not all, cases.
         */
-       if (tag != LDAP_REQ_ABANDON && conn->c_conn_state == SLAP_C_CLOSING) {
-               defer = "closing";
-       } else if (tag != LDAP_REQ_ABANDON && conn->c_writewaiter) {
-               defer = "awaiting write";
-       } else if (conn->c_n_ops_executing >= connection_pool_max/2) {
-               defer = "too many executing";
-       } else if (conn->c_conn_state == SLAP_C_BINDING) {
-               defer = "binding";
-       } else if (tag != LDAP_REQ_ABANDON && conn->c_n_ops_pending) {
-               defer = "pending operations";
+       switch( tag ){
+       default:
+               /* Abandon and Unbind are exempt from these checks */
+               if (conn->c_conn_state == SLAP_C_CLOSING) {
+                       defer = "closing";
+                       break;
+               } else if (conn->c_writewaiter) {
+                       defer = "awaiting write";
+                       break;
+               } else if (conn->c_n_ops_pending) {
+                       defer = "pending operations";
+                       break;
+               }
+               /* FALLTHRU */
+       case LDAP_REQ_ABANDON:
+               /* Unbind is exempt from these checks */
+               if (conn->c_n_ops_executing >= connection_pool_max/2) {
+                       defer = "too many executing";
+                       break;
+               } else if (conn->c_conn_state == SLAP_C_BINDING) {
+                       defer = "binding";
+                       break;
+               }
+               /* FALLTHRU */
+       case LDAP_REQ_UNBIND:
+               break;
        }
 
        if( defer ) {