1 /* unbind.c - ldap backend unbind function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1999-2006 The OpenLDAP Foundation.
6 * Portions Copyright 1999-2003 Howard Chu.
7 * Portions Copyright 2000-2003 Pierangelo Masarati.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
19 * This work was initially developed by the Howard Chu for inclusion
20 * in OpenLDAP Software and subsequently enhanced by Pierangelo
29 #include <ac/socket.h>
30 #include <ac/string.h>
33 #include "back-ldap.h"
36 ldap_back_conn_destroy(
41 ldapinfo_t *li = (ldapinfo_t *) be->be_private;
42 ldapconn_t *lc = NULL, lc_curr;
44 Debug( LDAP_DEBUG_TRACE,
45 "=>ldap_back_conn_destroy: fetching conn %ld\n",
46 conn->c_connid, 0, 0 );
48 lc_curr.lc_conn = conn;
50 ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
51 while ( ( lc = avl_delete( &li->li_conninfo.lai_tree, (caddr_t)&lc_curr, ldap_back_conn_cmp ) ) != NULL )
53 Debug( LDAP_DEBUG_TRACE,
54 "=>ldap_back_conn_destroy: destroying conn %ld (refcnt=%u)\n",
55 LDAP_BACK_PCONN_ID( lc->lc_conn ), lc->lc_refcnt, 0 );
57 assert( lc->lc_refcnt == 0 );
60 * Needs a test because the handler may be corrupted,
61 * and calling ldap_unbind on a corrupted header results
62 * in a segmentation fault
64 ldap_back_conn_free( lc );
66 ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );