]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/connection.c
More for prev commit
[openldap] / servers / slapd / connection.c
index c11c67e6485b54755ec9d8258098cb5b9d428e3d..969fcf1cc55be7bdcff9a80385190f3542afcadd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1185,8 +1185,6 @@ void connection_client_stop(
        /* get (locked) connection */
        c = connection_get( s );
 
-       if ( !c ) return;
-
        assert( c->c_conn_state == SLAP_C_CLIENT );
 
        c->c_listener = NULL;
@@ -1265,9 +1263,14 @@ connection_hangup( ber_socket_t s )
 
        c = connection_get( s );
        if ( c ) {
-               connection_closing( c, "connection lost" );
-               connection_close( c );
-               connection_return( c );
+               if ( c->c_conn_state == SLAP_C_CLIENT ) {
+                       connection_return( c );
+                       connection_read_activate( s );
+               } else {
+                       connection_closing( c, "connection lost" );
+                       connection_close( c );
+                       connection_return( c );
+               }
        }
 }
 
@@ -1856,7 +1859,9 @@ int connection_write(ber_socket_t s)
        Debug( LDAP_DEBUG_TRACE,
                "connection_write(%d): waking output for id=%lu\n",
                s, c->c_connid, 0 );
+       ldap_pvt_thread_mutex_lock( &c->c_write2_mutex );
        ldap_pvt_thread_cond_signal( &c->c_write2_cv );
+       ldap_pvt_thread_mutex_unlock( &c->c_write2_mutex );
 
        if ( ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_NEEDS_READ, NULL ) ) {
                slapd_set_read( s, 1 );