Lines Matching refs:lc

44 static void use_connection( LDAP *ld, LDAPConn *lc );
151 LDAPConn *lc, /* connection to use (NULL for default) */ in nsldapi_send_server_request() argument
164 if ( lc == NULL ) { in nsldapi_send_server_request()
185 lc = ld->ld_defconn; in nsldapi_send_server_request()
187 if (( lc = find_connection( ld, srvlist, 1 )) == in nsldapi_send_server_request()
195 lc = nsldapi_new_connection( ld, &srvlist, 0, in nsldapi_send_server_request()
213 if ( lc == NULL in nsldapi_send_server_request()
215 && lc->lconn_status != LDAP_CONNST_CONNECTING in nsldapi_send_server_request()
216 && lc->lconn_status != LDAP_CONNST_CONNECTED) in nsldapi_send_server_request()
218 && lc->lconn_status != LDAP_CONNST_CONNECTED) ) ) { in nsldapi_send_server_request()
221 if ( lc != NULL ) { in nsldapi_send_server_request()
232 use_connection( ld, lc ); in nsldapi_send_server_request()
240 nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 ); in nsldapi_send_server_request()
254 lr->lr_conn = lc; in nsldapi_send_server_request()
279 if (( err = nsldapi_ber_flush( ld, lc->lconn_sb, ber, 0, 1 )) != 0 ) { in nsldapi_send_server_request()
284 nsldapi_iostatus_interest_write( ld, lc->lconn_sb ); in nsldapi_send_server_request()
289 nsldapi_free_connection( ld, lc, NULL, NULL, 0, 0 ); in nsldapi_send_server_request()
303 lc->lconn_status = LDAP_CONNST_CONNECTED; in nsldapi_send_server_request()
306 nsldapi_iostatus_interest_read( ld, lc->lconn_sb ); in nsldapi_send_server_request()
363 LDAPConn *lc; in nsldapi_new_connection() local
370 if (( lc = (LDAPConn *)NSLDAPI_CALLOC( 1, sizeof( LDAPConn ))) == NULL in nsldapi_new_connection()
372 if ( lc != NULL ) { in nsldapi_new_connection()
373 NSLDAPI_FREE( (char *)lc ); in nsldapi_new_connection()
409 lc->lconn_sb = ( use_ldsb ) ? ld->ld_sbp : sb; in nsldapi_new_connection()
410 lc->lconn_version = ld->ld_version; /* inherited */ in nsldapi_new_connection()
419 rc = nsldapi_connect_to_host( ld, lc->lconn_sb, in nsldapi_new_connection()
422 &lc->lconn_krbinstance ); in nsldapi_new_connection()
431 NSLDAPI_FREE( (char *)lc->lconn_sb ); in nsldapi_new_connection()
433 NSLDAPI_FREE( (char *)lc ); in nsldapi_new_connection()
443 lc->lconn_server = srv; in nsldapi_new_connection()
448 lc->lconn_status = LDAP_CONNST_CONNECTING; in nsldapi_new_connection()
451 lc->lconn_status = LDAP_CONNST_CONNECTED; in nsldapi_new_connection()
454 lc->lconn_next = ld->ld_conns; in nsldapi_new_connection()
455 ld->ld_conns = lc; in nsldapi_new_connection()
485 ld->ld_defconn = lc; in nsldapi_new_connection()
486 ++lc->lconn_refcnt; /* avoid premature free */ in nsldapi_new_connection()
500 if ( lc->lconn_version <= LDAP_VERSION2 in nsldapi_new_connection()
505 --lc->lconn_version; /* try lower version */ in nsldapi_new_connection()
507 --lc->lconn_refcnt; in nsldapi_new_connection()
517 nsldapi_free_connection( ld, lc, NULL, NULL, 1, 0 ); in nsldapi_new_connection()
518 lc = NULL; in nsldapi_new_connection()
522 return( lc ); in nsldapi_new_connection()
537 LDAPConn *lc; in find_connection() local
540 for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { in find_connection()
543 lc->lconn_server->lsrv_host ) in find_connection()
544 && ls->lsrv_port == lc->lconn_server->lsrv_port in find_connection()
546 lc->lconn_server->lsrv_options ) { in find_connection()
547 return( lc ); in find_connection()
561 use_connection( LDAP *ld, LDAPConn *lc ) in use_connection() argument
563 ++lc->lconn_refcnt; in use_connection()
564 lc->lconn_lastused = time( 0 ); in use_connection()
569 nsldapi_free_connection( LDAP *ld, LDAPConn *lc, LDAPControl **serverctrls, in nsldapi_free_connection() argument
576 if ( force || --lc->lconn_refcnt <= 0 ) { in nsldapi_free_connection()
577 if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { in nsldapi_free_connection()
578 nsldapi_iostatus_interest_clear( ld, lc->lconn_sb ); in nsldapi_free_connection()
580 nsldapi_send_unbind( ld, lc->lconn_sb, in nsldapi_free_connection()
584 nsldapi_close_connection( ld, lc->lconn_sb ); in nsldapi_free_connection()
588 if ( tmplc == lc ) { in nsldapi_free_connection()
598 free_servers( lc->lconn_server ); in nsldapi_free_connection()
599 if ( lc->lconn_krbinstance != NULL ) { in nsldapi_free_connection()
600 NSLDAPI_FREE( lc->lconn_krbinstance ); in nsldapi_free_connection()
607 if ( lc->lconn_sb != ld->ld_sbp ) { in nsldapi_free_connection()
608 ber_sockbuf_free( lc->lconn_sb ); in nsldapi_free_connection()
609 lc->lconn_sb = NULL; in nsldapi_free_connection()
611 if ( lc->lconn_ber != NULLBER ) { in nsldapi_free_connection()
612 ber_free( lc->lconn_ber, 1 ); in nsldapi_free_connection()
614 if ( lc->lconn_binddn != NULL ) { in nsldapi_free_connection()
615 NSLDAPI_FREE( lc->lconn_binddn ); in nsldapi_free_connection()
617 NSLDAPI_FREE( lc ); in nsldapi_free_connection()
621 lc->lconn_lastused = time( 0 ); in nsldapi_free_connection()
623 lc->lconn_refcnt, 0, 0 ); in nsldapi_free_connection()
632 LDAPConn *lc; in nsldapi_dump_connection() local
641 for ( lc = lconns; lc != NULL; lc = lc->lconn_next ) { in nsldapi_dump_connection()
642 if ( lc->lconn_server != NULL ) { in nsldapi_dump_connection()
644 ( lc->lconn_server->lsrv_host == NULL ) ? "(null)" in nsldapi_dump_connection()
645 : lc->lconn_server->lsrv_host, in nsldapi_dump_connection()
646 lc->lconn_server->lsrv_port, in nsldapi_dump_connection()
647 ( lc->lconn_server->lsrv_options & in nsldapi_dump_connection()
649 "No", ( lc->lconn_sb == ld->ld_sbp ) ? in nsldapi_dump_connection()
653 sprintf( msg, " refcnt: %d status: %s\n", lc->lconn_refcnt, in nsldapi_dump_connection()
654 ( lc->lconn_status == LDAP_CONNST_NEEDSOCKET ) ? in nsldapi_dump_connection()
655 "NeedSocket" : ( lc->lconn_status == in nsldapi_dump_connection()
657 ( lc->lconn_status == LDAP_CONNST_DEAD ) ? "Dead" : in nsldapi_dump_connection()
661 NSLDAPI_CTIME( (time_t *) &lc->lconn_lastused, buf, in nsldapi_dump_connection()
664 if ( lc->lconn_ber != NULLBER ) { in nsldapi_dump_connection()
666 ber_dump( lc->lconn_ber, 1 ); in nsldapi_dump_connection()