Lines Matching defs:adh

475 	adutils_host_t	*adh;
480 for (adh = host_head; adh != NULL; adh = adh->next) {
481 (void) pthread_mutex_lock(&adh->lock);
482 if (adh->ref == 0 && adh->idletime != 0 &&
483 adh->idletime + ADCONN_TIME < now) {
484 if (adh->ld) {
485 (void) ldap_unbind(adh->ld);
486 adh->ld = NULL;
487 adh->idletime = 0;
488 adh->ref = 0;
491 (void) pthread_mutex_unlock(&adh->lock);
582 open_conn(adutils_host_t *adh, int timeoutsecs)
588 if (adh == NULL)
591 (void) pthread_mutex_lock(&adh->lock);
593 if (!adh->dead && adh->ld != NULL)
597 if (adh->ld != NULL) {
598 (void) ldap_unbind(adh->ld);
599 adh->ld = NULL;
601 adh->num_requests = 0;
603 atomic_inc_64(&adh->generation);
606 adh->ld = ldap_init(adh->host, adh->port);
607 if (adh->ld == NULL) {
609 "%s port %d failed. (%s)", adh->host,
610 adh->port, strerror(errno));
614 (void) ldap_set_option(adh->ld, LDAP_OPT_PROTOCOL_VERSION, &ldversion);
615 (void) ldap_set_option(adh->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
616 (void) ldap_set_option(adh->ld, LDAP_OPT_TIMELIMIT, &zero);
617 (void) ldap_set_option(adh->ld, LDAP_OPT_SIZELIMIT, &zero);
618 (void) ldap_set_option(adh->ld, LDAP_X_OPT_CONNECT_TIMEOUT, &timeoutms);
619 (void) ldap_set_option(adh->ld, LDAP_OPT_RESTART, LDAP_OPT_ON);
621 rc = adutils_set_thread_functions(adh->ld);
624 (void) ldap_unbind(adh->ld);
625 adh->ld = NULL;
632 (void) prldap_set_session_option(adh->ld, NULL,
635 rc = ldap_sasl_interactive_bind_s(adh->ld, "" /* binddn */,
636 adh->saslmech, NULL, NULL, adh->saslflags, &saslcallback,
640 (void) ldap_unbind(adh->ld);
641 adh->ld = NULL;
643 "%s port %d failed. (%s)", adh->host, adh->port,
649 adh->host, adh->port);
652 if (adh->ld != NULL) {
653 atomic_inc_32(&adh->ref);
654 adh->idletime = time(NULL);
655 adh->dead = 0;
656 (void) pthread_mutex_unlock(&adh->lock);
660 (void) pthread_mutex_unlock(&adh->lock);
672 adutils_host_t *adh = NULL;
693 for (adh = host_head, tries = 0; adh != NULL; adh = adh->next) {
694 if (adh->owner == ad)
710 adh = ad->last_adh;
719 if (adh != NULL && adh->owner == ad && adh->ld != NULL &&
720 !adh->dead)
722 if (adh == NULL || (adh = adh->next) == NULL)
723 adh = host_head;
724 if (adh->owner == ad)
728 ad->last_adh = adh;
732 if (open_conn(adh, timeoutsecs))
733 return (adh);
749 release_conn(adutils_host_t *adh)
753 (void) pthread_mutex_lock(&adh->lock);
754 if (atomic_dec_32_nv(&adh->ref) == 0) {
755 if (adh->owner == NULL)
757 adh->idletime = time(NULL);
759 (void) pthread_mutex_unlock(&adh->lock);
764 delete_ds(NULL, adh->host, adh->port);
966 adutils_host_t *adh = NULL;
972 adh = get_conn(ad);
973 if (adh == NULL)
982 new_state->qadh = adh;
984 new_state->qadh_gen = adh->generation;
1007 msgid2query(adutils_host_t *adh, int msgid,
1016 if (p->qadh != adh || adh->generation != p->qadh_gen)
1144 make_entry(adutils_q_t *q, adutils_host_t *adh, LDAPMessage *search_res,
1158 if ((dn = ldap_get_dn(adh->ld, search_res)) == NULL)
1181 for (attr = ldap_first_attribute(adh->ld, search_res, &ber);
1183 attr = ldap_next_attribute(adh->ld, search_res, ber)) {
1210 for (attr = ldap_first_attribute(adh->ld, search_res, &ber), i = 1;
1213 attr = ldap_next_attribute(adh->ld, search_res, ber)) {
1220 ldap_get_values_len(adh->ld, search_res, attr);
1246 strvalues = ldap_get_values(adh->ld, search_res, attr);
1277 add_entry(adutils_host_t *adh, adutils_q_t *q, LDAPMessage *search_res)
1283 ret = make_entry(q, adh, search_res, &entry);
1324 get_adobject_batch(adutils_host_t *adh, struct timeval *timeout)
1332 (void) pthread_mutex_lock(&adh->lock);
1333 if (adh->dead || adh->num_requests == 0) {
1334 ret = (adh->dead) ? -1 : -2;
1335 (void) pthread_mutex_unlock(&adh->lock);
1340 rc = ldap_result(adh->ld, LDAP_RES_ANY, 0, timeout, &res);
1343 adh->dead = 1;
1345 if (rc == LDAP_RES_SEARCH_RESULT && adh->num_requests > 0)
1346 adh->num_requests--;
1347 if (adh->dead) {
1348 num = adh->num_requests;
1349 (void) pthread_mutex_unlock(&adh->lock);
1358 if (msgid2query(adh, msgid, &query_state, &qid)) {
1365 adh->ld, &res, rc, qid,
1367 (void) pthread_mutex_unlock(&adh->lock);
1378 (void) pthread_mutex_unlock(&adh->lock);
1386 num = adh->num_requests;
1387 (void) pthread_mutex_unlock(&adh->lock);
1399 if (msgid2query(adh, msgid, &query_state, &qid)) {
1406 adh->ld, &res, rc, qid,
1408 (void) pthread_mutex_unlock(&adh->lock);
1416 rc = add_entry(adh, que, res);
1417 (void) pthread_mutex_unlock(&adh->lock);
1428 num = adh->num_requests;
1429 (void) pthread_mutex_unlock(&adh->lock);
1446 (void) pthread_mutex_unlock(&adh->lock);
1453 (void) pthread_mutex_unlock(&adh->lock);