Back to index

lightning-sunbird  0.9+nobinonly
Functions
unbind.c File Reference
#include "ldap-int.h"

Go to the source code of this file.

Functions

int LDAP_CALL ldap_unbind (LDAP *ld)
int LDAP_CALL ldap_unbind_s (LDAP *ld)
int LDAP_CALL ldap_unbind_ext (LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls)
int ldap_ld_free (LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls, int close)
int nsldapi_send_unbind (LDAP *ld, Sockbuf *sb, LDAPControl **serverctrls, LDAPControl **clientctrls)

Function Documentation

int ldap_ld_free ( LDAP *  ld,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls,
int  close 
)

Definition at line 86 of file unbind.c.

{
       LDAPMessage   *lm, *next;
       int           err = LDAP_SUCCESS;
       LDAPRequest   *lr, *nextlr;

       if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
              return( LDAP_PARAM_ERROR );
       }

       if ( ld->ld_sbp->sb_naddr == 0 ) {
              LDAP_MUTEX_LOCK( ld, LDAP_REQ_LOCK );
              /* free LDAP structure and outstanding requests/responses */
              for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
                     nextlr = lr->lr_next;
                     nsldapi_free_request( ld, lr, 0 );
              }
              LDAP_MUTEX_UNLOCK( ld, LDAP_REQ_LOCK );

              /* free and unbind from all open connections */
              LDAP_MUTEX_LOCK( ld, LDAP_CONN_LOCK );
              while ( ld->ld_conns != NULL ) {
                     nsldapi_free_connection( ld, ld->ld_conns, serverctrls,
                         clientctrls, 1, close );
              }
              LDAP_MUTEX_UNLOCK( ld, LDAP_CONN_LOCK );

       } else {
              int    i;

              for ( i = 0; i < ld->ld_sbp->sb_naddr; ++i ) {
                     NSLDAPI_FREE( ld->ld_sbp->sb_addrs[ i ] );
              }
              NSLDAPI_FREE( ld->ld_sbp->sb_addrs );
              NSLDAPI_FREE( ld->ld_sbp->sb_fromaddr );
       }

       LDAP_MUTEX_LOCK( ld, LDAP_RESP_LOCK );
       for ( lm = ld->ld_responses; lm != NULL; lm = next ) {
              next = lm->lm_next;
              ldap_msgfree( lm );
       }
       LDAP_MUTEX_UNLOCK( ld, LDAP_RESP_LOCK );

       /* call cache unbind function to allow it to clean up after itself */
       if ( ld->ld_cache_unbind != NULL ) {
              LDAP_MUTEX_LOCK( ld, LDAP_CACHE_LOCK );
              (void)ld->ld_cache_unbind( ld, 0, 0 );
              LDAP_MUTEX_UNLOCK( ld, LDAP_CACHE_LOCK );
       }

       /* call the dispose handle I/O callback if one is defined */
       if ( ld->ld_extdisposehandle_fn != NULL ) {
           /*
            * We always pass the session extended I/O argument to
            * the dispose handle callback.
            */
           ld->ld_extdisposehandle_fn( ld, ld->ld_ext_session_arg );
       }

       if ( ld->ld_error != NULL )
              NSLDAPI_FREE( ld->ld_error );
       if ( ld->ld_matched != NULL )
              NSLDAPI_FREE( ld->ld_matched );
       if ( ld->ld_host != NULL )
              NSLDAPI_FREE( ld->ld_host );
       if ( ld->ld_ufnprefix != NULL )
              NSLDAPI_FREE( ld->ld_ufnprefix );
       if ( ld->ld_filtd != NULL )
              ldap_getfilter_free( ld->ld_filtd );
       if ( ld->ld_abandoned != NULL )
              NSLDAPI_FREE( ld->ld_abandoned );
       if ( ld->ld_sbp != NULL )
              ber_sockbuf_free( ld->ld_sbp );
       if ( ld->ld_defhost != NULL )
              NSLDAPI_FREE( ld->ld_defhost );
       if ( ld->ld_servercontrols != NULL )
              ldap_controls_free( ld->ld_servercontrols );
       if ( ld->ld_clientcontrols != NULL )
              ldap_controls_free( ld->ld_clientcontrols );
       if ( ld->ld_preferred_language != NULL )
              NSLDAPI_FREE( ld->ld_preferred_language );
       nsldapi_iostatus_free( ld );

       /*
        * XXXmcs: should use cache function pointers to hook in memcache
        */
       if ( ld->ld_memcache != NULL ) {
              ldap_memcache_set( ld, NULL );
       }

       /* free all mutexes we have allocated */
       nsldapi_mutex_free_all( ld );
       NSLDAPI_FREE( ld->ld_mutex );

       NSLDAPI_FREE( (char *) ld );

       return( err );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int LDAP_CALL ldap_unbind ( LDAP *  ld)

Definition at line 56 of file unbind.c.

{
       LDAPDebug( LDAP_DEBUG_TRACE, "ldap_unbind\n", 0, 0, 0 );

       return( ldap_ld_free( ld, NULL, NULL, 1 ) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int LDAP_CALL ldap_unbind_ext ( LDAP *  ld,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls 
)

Definition at line 74 of file unbind.c.

{
       return( ldap_ld_free( ld, serverctrls, clientctrls, 1 ));
}

Here is the call graph for this function:

int LDAP_CALL ldap_unbind_s ( LDAP *  ld)

Definition at line 66 of file unbind.c.

{
       return( ldap_ld_free( ld, NULL, NULL, 1 ));
}

Here is the call graph for this function:

int nsldapi_send_unbind ( LDAP *  ld,
Sockbuf *  sb,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls 
)

Definition at line 190 of file unbind.c.

{
       BerElement    *ber;
       int           err, msgid;

       LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_send_unbind\n", 0, 0, 0 );

       /* create a message to send */
       if (( err = nsldapi_alloc_ber_with_options( ld, &ber ))
           != LDAP_SUCCESS ) {
              return( err );
       }

       /* fill it in */
       LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK );
       msgid = ++ld->ld_msgid;
       LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK );

       if ( ber_printf( ber, "{itn", msgid, LDAP_REQ_UNBIND ) == -1 ) {
              ber_free( ber, 1 );
              err = LDAP_ENCODING_ERROR;
              LDAP_SET_LDERRNO( ld, err, NULL, NULL );
              return( err );
       }

       if (( err = nsldapi_put_controls( ld, serverctrls, 1, ber ))
           != LDAP_SUCCESS ) {
              ber_free( ber, 1 );
              return( err );
       }

       /* send the message */
       if ( nsldapi_ber_flush( ld, sb, ber, 1, 0 ) != 0 ) {
              ber_free( ber, 1 );
              err = LDAP_SERVER_DOWN;
              LDAP_SET_LDERRNO( ld, err, NULL, NULL );
              return( err );
       }

       return( LDAP_SUCCESS );
}

Here is the call graph for this function:

Here is the caller graph for this function: