~ubuntu-branches/ubuntu/maverick/openldap/maverick-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/connection.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-09-07 13:41:10 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090907134110-jsdrvn0atu1fex4m
Tags: upstream-2.4.18
ImportĀ upstreamĀ versionĀ 2.4.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $OpenLDAP: pkg/ldap/servers/slapd/connection.c,v 1.358.2.31 2009/06/28 19:41:27 quanah Exp $ */
 
1
/* $OpenLDAP: pkg/ldap/servers/slapd/connection.c,v 1.358.2.34 2009/08/28 22:39:45 quanah Exp $ */
2
2
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3
3
 *
4
4
 * Copyright 1998-2009 The OpenLDAP Foundation.
242
242
                        continue;
243
243
                }
244
244
 
245
 
                if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) {
 
245
                if( global_idletimeout && 
 
246
                        difftime( c->c_activitytime+global_idletimeout, now) < 0 ) {
246
247
                        /* close it */
247
248
                        connection_closing( c, "idletimeout" );
248
249
                        connection_close( c );
249
250
                        i++;
250
251
                        continue;
251
252
                }
252
 
                if ( c->c_writewaiter ) {
 
253
                if ( c->c_writewaiter && global_writetimeout ) {
253
254
                        writers = 1;
254
255
                        if( difftime( c->c_activitytime+global_writetimeout, now) < 0 ) {
255
256
                                /* close it */
260
261
                }
261
262
        }
262
263
        connection_done( c );
263
 
        if ( !writers )
 
264
        if ( old && !writers )
264
265
                slapd_clr_writetime( old );
265
266
 
266
267
        return i;
752
753
        }
753
754
}
754
755
 
 
756
static void
 
757
connection_wake_writers( Connection *c )
 
758
{
 
759
        /* wake write blocked operations */
 
760
        ldap_pvt_thread_mutex_lock( &c->c_write1_mutex );
 
761
        if ( c->c_writers > 0 ) {
 
762
                c->c_writers = -c->c_writers;
 
763
                ldap_pvt_thread_cond_broadcast( &c->c_write1_cv );
 
764
                ldap_pvt_thread_mutex_unlock( &c->c_write1_mutex );
 
765
                if ( c->c_writewaiter ) {
 
766
                        ldap_pvt_thread_mutex_lock( &c->c_write2_mutex );
 
767
                        ldap_pvt_thread_cond_signal( &c->c_write2_cv );
 
768
                        slapd_clr_write( c->c_sd, 1 );
 
769
                        ldap_pvt_thread_mutex_unlock( &c->c_write2_mutex );
 
770
                }
 
771
                ldap_pvt_thread_mutex_lock( &c->c_write1_mutex );
 
772
                while ( c->c_writers ) {
 
773
                        ldap_pvt_thread_cond_wait( &c->c_write1_cv, &c->c_write1_mutex );
 
774
                }
 
775
                ldap_pvt_thread_mutex_unlock( &c->c_write1_mutex );
 
776
        } else {
 
777
                ldap_pvt_thread_mutex_unlock( &c->c_write1_mutex );
 
778
                slapd_clr_write( c->c_sd, 1 );
 
779
        }
 
780
}
 
781
 
755
782
void connection_closing( Connection *c, const char *why )
756
783
{
757
784
        assert( connections != NULL );
776
803
                connection_abandon( c );
777
804
 
778
805
                /* wake write blocked operations */
779
 
                ldap_pvt_thread_mutex_lock( &c->c_write1_mutex );
780
 
                if ( c->c_writers > 0 ) {
781
 
                        c->c_writers = -c->c_writers;
782
 
                        ldap_pvt_thread_cond_broadcast( &c->c_write1_cv );
783
 
                        ldap_pvt_thread_mutex_unlock( &c->c_write1_mutex );
784
 
                        if ( c->c_writewaiter ) {
785
 
                                ldap_pvt_thread_mutex_lock( &c->c_write2_mutex );
786
 
                                ldap_pvt_thread_cond_signal( &c->c_write2_cv );
787
 
                                slapd_clr_write( c->c_sd, 1 );
788
 
                                ldap_pvt_thread_mutex_unlock( &c->c_write2_mutex );
789
 
                        }
790
 
                        ldap_pvt_thread_mutex_lock( &c->c_write1_mutex );
791
 
                        while ( c->c_writers ) {
792
 
                                ldap_pvt_thread_cond_wait( &c->c_write1_cv, &c->c_write1_mutex );
793
 
                        }
794
 
                        ldap_pvt_thread_mutex_unlock( &c->c_write1_mutex );
795
 
                } else {
796
 
                        ldap_pvt_thread_mutex_unlock( &c->c_write1_mutex );
797
 
                        slapd_clr_write( c->c_sd, 1 );
798
 
                }
 
806
                connection_wake_writers( c );
799
807
 
800
808
        } else if( why == NULL && c->c_close_reason == conn_lost_str ) {
801
809
                /* Client closed connection after doing Unbind. */
1269
1277
        if ( rc )
1270
1278
                return rc;
1271
1279
 
 
1280
        /* Don't let blocked writers block a pause request */
 
1281
        if ( connections[s].c_writewaiter &&
 
1282
                ldap_pvt_thread_pool_pausing( &connection_pool ))
 
1283
                connection_wake_writers( &connections[s] );
 
1284
 
1272
1285
        rc = ldap_pvt_thread_pool_submit( &connection_pool,
1273
1286
                connection_read_thread, (void *)(long)s );
1274
1287