]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/connection.c
More for ITS#6045: clear o_callback as well.
[openldap] / servers / slapd / connection.c
index 9e2130d6de68917c410a1674d445a1ecbc230e0a..6781d2a34f92d271c863ff4622c3495a85011cd2 100644 (file)
@@ -218,9 +218,12 @@ int connections_shutdown(void)
  */
 int connections_timeout_idle(time_t now)
 {
-       int i = 0;
+       int i = 0, writers = 0;
        int connindex;
        Connection* c;
+       time_t old;
+
+       old = slapd_get_writetime();
 
        for( c = connection_first( &connindex );
                c != NULL;
@@ -240,9 +243,21 @@ int connections_timeout_idle(time_t now)
                        connection_closing( c, "idletimeout" );
                        connection_close( c );
                        i++;
+                       continue;
+               }
+               if ( c->c_writewaiter ) {
+                       writers = 1;
+                       if( difftime( c->c_activitytime+global_writetimeout, now) < 0 ) {
+                               /* close it */
+                               connection_closing( c, "writetimeout" );
+                               connection_close( c );
+                               i++;
+                       }
                }
        }
        connection_done( c );
+       if ( !writers )
+               slapd_clr_writetime( old );
 
        return i;
 }
@@ -1859,7 +1874,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 );