2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2005 The OpenLDAP Foundation.
5 * Portions Copyright 2001-2003 Pierangelo Masarati.
6 * Portions Copyright 1999-2003 Howard Chu.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by the Howard Chu for inclusion
19 * in OpenLDAP Software and subsequently enhanced by Pierangelo
28 #include <ac/socket.h>
29 #include <ac/string.h>
32 #include "../back-ldap/back-ldap.h"
33 #include "back-meta.h"
36 meta_back_conn_destroy(
40 metainfo_t *mi = ( metainfo_t * )be->be_private;
46 Debug( LDAP_DEBUG_TRACE,
47 "=>meta_back_conn_destroy: fetching conn %ld\n",
48 conn->c_connid, 0, 0 );
50 mc_curr.mc_conn = conn;
52 ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex );
53 mc = avl_delete( &mi->mi_conntree, ( caddr_t )&mc_curr,
55 ldap_pvt_thread_mutex_unlock( &mi->mi_conn_mutex );
58 Debug( LDAP_DEBUG_TRACE,
59 "=>meta_back_conn_destroy: destroying conn %ld\n",
60 mc->mc_conn->c_connid, 0, 0 );
62 assert( mc->mc_refcnt == 0 );
65 * Cleanup rewrite session
67 for ( i = 0; i < mi->mi_ntargets; ++i ) {
68 if ( mc->mc_conns[ i ].msc_ld != NULL ) {
69 meta_clear_one_candidate( &mc->mc_conns[ i ] );
73 meta_back_conn_free( mc );
77 * Cleanup rewrite session
79 for ( i = 0; i < mi->mi_ntargets; ++i ) {
80 rewrite_session_delete( mi->mi_targets[ i ].mt_rwmap.rwm_rw, conn );