#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include <ac/string.h>
#include "slap.h"
#include "../back-ldap/back-ldap.h"
#include "back-meta.h"
int
meta_back_conn_destroy(
Backend *be,
Connection *conn
)
{
struct metainfo *li = ( struct metainfo * )be->be_private;
struct metaconn *lc, lc_curr;
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, ENTRY,
"meta_back_conn_destroy: fetching conn %ld\n", conn->c_connid, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_conn_destroy: fetching conn %ld\n%s%s",
conn->c_connid, "", "" );
#endif
lc_curr.conn = conn;
ldap_pvt_thread_mutex_lock( &li->conn_mutex );
lc = avl_delete( &li->conntree, ( caddr_t )&lc_curr,
meta_back_conn_cmp );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
if ( lc ) {
int i;
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, INFO,
"meta_back_conn_destroy: destroying conn %ld\n",
lc->conn->c_connid, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_conn_destroy: destroying conn %ld\n%s%s",
lc->conn->c_connid, "", "" );
#endif
for ( i = 0; i < li->ntargets; ++i ) {
if ( lc->conns[ i ].ld == NULL ) {
continue;
}
rewrite_session_delete( li->targets[ i ]->rwmap.rwm_rw, conn );
meta_clear_one_candidate( &lc->conns[ i ], 1 );
}
free( lc->conns );
free( lc );
}
return 0;
}