openldap/servers/slapd/back-meta/unbind.c

83 lines
1.9 KiB
C
Raw Normal View History

2003-11-27 14:35:14 +08:00
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
2005-01-02 04:49:32 +08:00
* Copyright 1999-2005 The OpenLDAP Foundation.
2003-12-09 01:41:40 +08:00
* Portions Copyright 2001-2003 Pierangelo Masarati.
* Portions Copyright 1999-2003 Howard Chu.
2003-11-27 14:35:14 +08:00
* All rights reserved.
*
2003-11-27 14:35:14 +08:00
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* ACKNOWLEDGEMENTS:
* This work was initially developed by the Howard Chu for inclusion
* in OpenLDAP Software and subsequently enhanced by Pierangelo
* Masarati.
*/
#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;
2005-01-08 17:20:54 +08:00
struct metaconn *lc,
lc_curr = { 0 };
Debug( LDAP_DEBUG_TRACE,
2005-01-08 17:20:54 +08:00
"=>meta_back_conn_destroy: fetching conn %ld\n",
conn->c_connid, 0, 0 );
2005-01-08 17:20:54 +08:00
lc_curr.mc_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;
Debug( LDAP_DEBUG_TRACE,
2005-01-08 17:20:54 +08:00
"=>meta_back_conn_destroy: destroying conn %ld\n",
lc->mc_conn->c_connid, 0, 0 );
/*
* Cleanup rewrite session
*/
for ( i = 0; i < li->ntargets; ++i ) {
2005-01-08 17:20:54 +08:00
if ( lc->mc_conns[ i ].msc_ld == NULL ) {
continue;
}
2005-01-08 17:20:54 +08:00
rewrite_session_delete( li->targets[ i ]->mt_rwmap.rwm_rw, conn );
meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
}
2005-01-08 17:20:54 +08:00
free( lc->mc_conns );
free( lc );
}
/* no response to unbind */
return 0;
}