mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
Reuse connection_walk for client matters
This commit is contained in:
parent
b4f43ed8e1
commit
3bd2d7483e
@ -554,39 +554,10 @@ client_destroy( LloadConnection *c )
|
||||
}
|
||||
|
||||
void
|
||||
clients_destroy( void )
|
||||
clients_destroy( int gentle )
|
||||
{
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
while ( !LDAP_CIRCLEQ_EMPTY( &clients ) ) {
|
||||
LloadConnection *c = LDAP_CIRCLEQ_FIRST( &clients );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
CONNECTION_LOCK(c);
|
||||
/* We have shut down all processing, a dying connection connection
|
||||
* should have been reclaimed by now! */
|
||||
assert( c->c_live );
|
||||
/* Upstream connections have already been destroyed, there should be no
|
||||
* ops left */
|
||||
assert( !c->c_ops );
|
||||
CONNECTION_DESTROY(c);
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
}
|
||||
|
||||
void
|
||||
clients_walk( CONNCB apply, void *argv )
|
||||
{
|
||||
LloadConnection *c;
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
if ( LDAP_CIRCLEQ_EMPTY( &clients ) ) {
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Todo is it possible to do this without holding this lock? */
|
||||
LDAP_CIRCLEQ_FOREACH ( c, &clients, c_next ) {
|
||||
apply( c, argv );
|
||||
}
|
||||
connections_walk(
|
||||
&clients_mutex, &clients, lload_connection_close, &gentle );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
}
|
||||
|
@ -1396,6 +1396,9 @@ lloadd_daemon( struct event_base *daemon_base )
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
}
|
||||
|
||||
/* Do the same for clients */
|
||||
clients_destroy( 1 );
|
||||
|
||||
for ( i = 0; i < lload_daemon_threads; i++ ) {
|
||||
/*
|
||||
* https://github.com/libevent/libevent/issues/623
|
||||
@ -1420,7 +1423,7 @@ lloadd_daemon( struct event_base *daemon_base )
|
||||
#endif
|
||||
|
||||
lload_backends_destroy();
|
||||
clients_destroy();
|
||||
clients_destroy( 0 );
|
||||
lload_bindconf_free( &bindconf );
|
||||
evdns_base_free( dnsbase, 0 );
|
||||
|
||||
|
@ -548,7 +548,10 @@ lload_monitor_in_conn_create(
|
||||
mp_parent = e_parent->e_private;
|
||||
arg.ms = (monitor_subsys_t *)mp_parent->mp_info;
|
||||
|
||||
clients_walk( lload_monitor_in_conn_entry, &arg );
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
connections_walk(
|
||||
&clients_mutex, &clients, lload_monitor_in_conn_entry, &arg );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -935,8 +938,12 @@ lload_monitor_update_global_stats( void *ctx, void *arg )
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "lload_monitor_update_global_stats: "
|
||||
"updating stats\n" );
|
||||
|
||||
/* count incoming connections */
|
||||
clients_walk( lload_monitor_incoming_count, &tmp_stats );
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
connections_walk( &clients_mutex, &clients, lload_monitor_incoming_count,
|
||||
&tmp_stats );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
|
||||
LDAP_CIRCLEQ_FOREACH ( b, &backend, b_next ) {
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
|
@ -63,8 +63,7 @@ LDAP_SLAPD_F (void) client_tls_handshake_cb( evutil_socket_t s, short what, void
|
||||
LDAP_SLAPD_F (LloadConnection *) client_init( ber_socket_t s, LloadListener *url, const char *peername, struct event_base *base, int use_tls );
|
||||
LDAP_SLAPD_F (void) client_reset( LloadConnection *c );
|
||||
LDAP_SLAPD_F (void) client_destroy( LloadConnection *c );
|
||||
LDAP_SLAPD_F (void) clients_destroy( void );
|
||||
LDAP_SLAPD_F (void) clients_walk( CONNCB apply, void *argv );
|
||||
LDAP_SLAPD_F (void) clients_destroy( int gentle );
|
||||
|
||||
/*
|
||||
* config.c
|
||||
|
Loading…
Reference in New Issue
Block a user