Lines Matching refs:lc

442 exclusiveLC(__nis_ldap_conn_t *lc) {  in exclusiveLC()  argument
446 if (lc == 0) in exclusiveLC()
449 stat = mutex_trylock(&lc->mutex); in exclusiveLC()
450 if (stat == EBUSY && lc->owner != me) in exclusiveLC()
451 mutex_lock(&lc->mutex); in exclusiveLC()
453 lc->owner = me; in exclusiveLC()
458 assertExclusive(__nis_ldap_conn_t *lc) { in assertExclusive() argument
462 if (lc == 0) in assertExclusive()
465 stat = mutex_trylock(&lc->mutex); in assertExclusive()
468 mutex_unlock(&lc->mutex); in assertExclusive()
473 if (stat != EBUSY || lc->owner != me) in assertExclusive()
480 releaseLC(__nis_ldap_conn_t *lc) { in releaseLC() argument
483 if (lc == 0 || lc->owner != me) in releaseLC()
486 lc->owner = 0; in releaseLC()
487 (void) mutex_unlock(&lc->mutex); in releaseLC()
491 incrementRC(__nis_ldap_conn_t *lc) { in incrementRC() argument
492 if (lc == 0) in incrementRC()
495 (void) mutex_lock(&lc->rcMutex); in incrementRC()
496 lc->refCount++; in incrementRC()
497 (void) mutex_unlock(&lc->rcMutex); in incrementRC()
501 decrementRC(__nis_ldap_conn_t *lc) { in decrementRC() argument
502 if (lc == 0) in decrementRC()
505 (void) mutex_lock(&lc->rcMutex); in decrementRC()
506 if (lc->refCount > 0) in decrementRC()
507 lc->refCount--; in decrementRC()
508 (void) mutex_unlock(&lc->rcMutex); in decrementRC()
620 freeCon(__nis_ldap_conn_t *lc) { in freeCon() argument
622 if (!assertExclusive(lc)) in freeCon()
625 incrementRC(lc); in freeCon()
628 if (lc->onList || lc->refCount != 1 || lc->isBound) { in freeCon()
629 lc->doDel++; in freeCon()
630 decrementRC(lc); in freeCon()
634 sfree(lc->sp); in freeCon()
635 sfree(lc->who); in freeCon()
636 sfree(lc->cred); in freeCon()
640 free(lc); in freeCon()
652 disconnectCon(__nis_ldap_conn_t *lc) { in disconnectCon() argument
656 if (lc == 0) in disconnectCon()
659 if (!assertExclusive(lc)) in disconnectCon()
662 if (lc->doDis) { in disconnectCon()
665 incrementRC(lc); in disconnectCon()
667 if (lc->refCount != 1) { in disconnectCon()
672 decrementRC(lc); in disconnectCon()
676 stat = ldap_unbind_s(lc->ld); in disconnectCon()
678 lc->ld = 0; in disconnectCon()
679 lc->isBound = 0; in disconnectCon()
680 lc->doDis = 0; in disconnectCon()
682 lc->simplePage = 0; in disconnectCon()
683 lc->vlv = 0; in disconnectCon()
690 decrementRC(lc); in disconnectCon()
693 if (lc->doDel) { in disconnectCon()
694 if (LDAP_UNAVAILABLE == freeCon(lc)) in disconnectCon()
714 controlSupported(__nis_ldap_conn_t *lc, char **ctrl, bool_t *supported) { in controlSupported() argument
724 stat = ldap_search_st(lc->ld, "", LDAP_SCOPE_BASE, "(objectclass=*)", in controlSupported()
725 attr, 0, &lc->searchTimeout, &res); in controlSupported()
729 myself, NIL(lc->sp), ldap_err2string(stat)); in controlSupported()
733 e = ldap_first_entry(lc->ld, res); in controlSupported()
735 a = ldap_first_attribute(lc->ld, e, &ber); in controlSupported()
737 val = ldap_get_values(lc->ld, e, a); in controlSupported()
749 myself, NIL(lc->sp)); in controlSupported()
763 myself, NIL(lc->sp), NIL(*ctrl), in controlSupported()
786 connectCon(__nis_ldap_conn_t *lc, int check_ctrl) { in connectCon() argument
794 if (lc == 0) in connectCon()
797 if (!assertExclusive(lc)) in connectCon()
800 incrementRC(lc); in connectCon()
801 if (lc->refCount != 1) { in connectCon()
806 decrementRC(lc); in connectCon()
812 if (lc->ld != 0) { in connectCon()
814 lc->doDis++; in connectCon()
815 decrementRC(lc); in connectCon()
817 stat = disconnectCon(lc); in connectCon()
820 incrementRC(lc); in connectCon()
821 if (lc->refCount != 1 || lc->ld != 0) { in connectCon()
822 decrementRC(lc); in connectCon()
823 return (lc->ld != 0) ? LDAP_SUCCESS : in connectCon()
826 } else if (tp.tv_sec < lc->retryTime) { in connectCon()
828 decrementRC(lc); in connectCon()
833 lc->retryTime = tp.tv_sec + ldapConnAttemptRetryTimeout; in connectCon()
835 lc->ld = ldapInit(lc->sp, lc->port, proxyInfo.tls_method != no_tls); in connectCon()
836 if (lc->ld == 0) { in connectCon()
837 decrementRC(lc); in connectCon()
841 stat = lc->status = ldapBind(&lc->ld, lc->who, lc->cred, lc->method, in connectCon()
842 lc->bindTimeout); in connectCon()
843 if (lc->status == LDAP_SUCCESS) { in connectCon()
844 lc->isBound = 1; in connectCon()
845 lc->retryTime = 0; in connectCon()
847 (void) controlSupported(lc, ctrl, supported); in connectCon()
848 lc->simplePage = supported[0]; in connectCon()
849 lc->vlv = supported[1]; in connectCon()
850 lc->batchFrom = 50000; in connectCon()
854 decrementRC(lc); in connectCon()
864 __nis_ldap_conn_t *lc; in findCon() local
885 for (lc = ldapCon; lc != 0; lc = lc->next) { in findCon()
886 exclusiveLC(lc); in findCon()
887 if (!lc->isBound) { in findCon()
888 *stat = connectCon(lc, 1); in findCon()
893 myself, NIL(lc->sp), in findCon()
895 releaseLC(lc); in findCon()
899 } else if (lc->doDis || lc->doDel) { in findCon()
900 *stat = disconnectCon(lc); in findCon()
902 releaseLC(lc); in findCon()
905 incrementRC(lc); in findCon()
906 releaseLC(lc); in findCon()
912 return (lc); in findCon()
917 releaseCon(__nis_ldap_conn_t *lc, int status) { in releaseCon() argument
920 if (lc == 0) in releaseCon()
923 exclusiveLC(lc); in releaseCon()
925 lc->status = status; in releaseCon()
927 decrementRC(lc); in releaseCon()
929 if (lc->doDis) in releaseCon()
930 stat = disconnectCon(lc); in releaseCon()
935 releaseLC(lc); in releaseCon()
940 __nis_ldap_conn_t *lc; in createCon() local
947 lc = am(myself, sizeof (*lc)); in createCon()
948 if (lc == 0) in createCon()
951 (void) mutex_init(&lc->mutex, 0, 0); in createCon()
952 (void) mutex_init(&lc->rcMutex, 0, 0); in createCon()
955 exclusiveLC(lc); in createCon()
957 lc->sp = sdup(myself, T, sp); in createCon()
958 if (lc->sp == 0) { in createCon()
959 (void) freeCon(lc); in createCon()
963 if ((r = strchr(lc->sp, ']')) != 0) { in createCon()
970 r = strchr(lc->sp, ':'); in createCon()
980 lc->who = sdup(myself, T, who); in createCon()
981 if (lc->who == 0) { in createCon()
982 (void) freeCon(lc); in createCon()
988 lc->cred = sdup(myself, T, cred); in createCon()
989 if (lc->cred == 0) { in createCon()
990 (void) freeCon(lc); in createCon()
995 lc->method = method; in createCon()
996 lc->port = port; in createCon()
998 lc->bindTimeout = proxyInfo.bind_timeout; in createCon()
999 lc->searchTimeout = proxyInfo.search_timeout; in createCon()
1000 lc->modifyTimeout = proxyInfo.modify_timeout; in createCon()
1001 lc->addTimeout = proxyInfo.add_timeout; in createCon()
1002 lc->deleteTimeout = proxyInfo.delete_timeout; in createCon()
1006 releaseLC(lc); in createCon()
1008 return (lc); in createCon()
1014 __nis_ldap_conn_t *lc, *tmp; in setupConList() local
1051 lc = createCon(s, who, cred, method, 0); in setupConList()
1052 if (lc == 0) { in setupConList()
1057 lc->onList = 1; in setupConList()
1059 ldapCon = lc; in setupConList()
1064 tmp->next = lc; in setupConList()
1077 is_same_connection(__nis_ldap_conn_t *lc, LDAPURLDesc *ludpp) in is_same_connection() argument
1079 return (strcasecmp(ludpp->lud_host, lc->sp) == 0 && in is_same_connection()
1080 ludpp->lud_port == lc->port); in is_same_connection()
1088 __nis_ldap_conn_t *lc = NULL; in find_connection_from_list() local
1094 for (lc = list; lc != 0; lc = lc->next) { in find_connection_from_list()
1095 exclusiveLC(lc); in find_connection_from_list()
1096 if (is_same_connection(lc, ludpp)) { in find_connection_from_list()
1097 if (!lc->isBound) { in find_connection_from_list()
1098 *stat = connectCon(lc, 1); in find_connection_from_list()
1100 releaseLC(lc); in find_connection_from_list()
1103 } else if (lc->doDis || lc->doDel) { in find_connection_from_list()
1104 (void) disconnectCon(lc); in find_connection_from_list()
1105 releaseLC(lc); in find_connection_from_list()
1108 incrementRC(lc); in find_connection_from_list()
1109 releaseLC(lc); in find_connection_from_list()
1112 releaseLC(lc); in find_connection_from_list()
1114 return (lc); in find_connection_from_list()
1120 __nis_ldap_conn_t *lc = NULL; in findReferralCon() local
1164 lc = find_connection_from_list(ldapReferralCon, ludpp, stat); in findReferralCon()
1165 if (lc == NULL) in findReferralCon()
1166 lc = find_connection_from_list(ldapCon, ludpp, stat); in findReferralCon()
1168 if (lc != NULL) { in findReferralCon()
1170 return (lc); in findReferralCon()
1191 lc = createCon(ludpp->lud_host, proxyInfo.proxy_dn, in findReferralCon()
1195 if (lc == 0) { in findReferralCon()
1205 lc->onList = 1; in findReferralCon()
1207 ldapReferralCon = lc; in findReferralCon()
1212 tmp->next = lc; in findReferralCon()
1214 lc = find_connection_from_list(ldapReferralCon, ludpp, stat); in findReferralCon()
1216 if (lc != NULL) in findReferralCon()
1220 if (lc == NULL) { in findReferralCon()
1226 return (lc); in findReferralCon()
1235 __nis_ldap_conn_t *lc, *newlc; in findYPCon() local
1256 for (lc = ldapCon; lc != 0; lc = lc->next) { in findYPCon()
1257 exclusiveLC(lc); in findYPCon()
1259 if (lc->isBound && (lc->doDis || lc->doDel)) { in findYPCon()
1260 *stat = disconnectCon(lc); in findYPCon()
1262 releaseLC(lc); in findYPCon()
1272 newlc = createCon(lc->sp, lc->who, lc->cred, in findYPCon()
1273 lc->method, lc->port); in findYPCon()
1275 releaseLC(lc); in findYPCon()
1278 if (lc->ld != 0) { in findYPCon()
1279 newlc->simplePage = lc->simplePage; in findYPCon()
1280 newlc->vlv = lc->vlv; in findYPCon()
1281 newlc->batchFrom = lc->batchFrom; in findYPCon()
1283 releaseLC(lc); in findYPCon()
1304 lc = newlc; in findYPCon()
1305 } else if (!lc->isBound) { in findYPCon()
1306 *stat = connectCon(lc, 1); in findYPCon()
1311 myself, NIL(lc->sp), in findYPCon()
1313 releaseLC(lc); in findYPCon()
1319 incrementRC(lc); in findYPCon()
1320 releaseLC(lc); in findYPCon()
1326 return (lc); in findYPCon()
1351 __nis_ldap_conn_t *lc; in ldapSearch() local
1379 if ((lc = findYPCon(ls, ldapStat)) == 0) { in ldapSearch()
1384 if ((lc = findCon(ldapStat)) == 0) { in ldapSearch()
1395 if (doIndex && lc->vlv) { in ldapSearch()
1406 stat = ldap_create_sort_control(lc->ld, sortKeyList, 1, in ldapSearch()
1410 vList.ldvlist_after_count = lc->batchFrom - 1; in ldapSearch()
1416 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &stat); in ldapSearch()
1428 if (doIndex && !doVLV && lc->simplePage) { in ldapSearch()
1454 tv = lc->searchTimeout; in ldapSearch()
1465 stat = ldap_create_virtuallist_control(lc->ld, in ldapSearch()
1468 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapSearch()
1481 stat = ldap_search_ext_s(lc->ld, ls->base, in ldapSearch()
1489 stat = ldap_create_page_control(lc->ld, in ldapSearch()
1490 lc->batchFrom, spCookie, 0, &ctrls[0]); in ldapSearch()
1494 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapSearch()
1505 stat = ldap_search_ext_s(lc->ld, ls->base, in ldapSearch()
1510 stat = ldap_search_st(lc->ld, ls->base, ls->scope, in ldapSearch()
1515 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &stat); in ldapSearch()
1518 lc->doDis++; in ldapSearch()
1519 releaseCon(lc, stat); in ldapSearch()
1520 lc = (yp2ldap)?findYPCon(ls, ldapStat): in ldapSearch()
1522 if (lc == 0) { in ldapSearch()
1531 (void) ldap_parse_result(lc->ld, msg, NULL, NULL, NULL, in ldapSearch()
1536 releaseCon(lc, stat); in ldapSearch()
1537 lc = findReferralCon(referralsp, &stat); in ldapSearch()
1539 if (lc == NULL) { in ldapSearch()
1577 myself, NIL(lc->sp)); in ldapSearch()
1582 lc->ld, NIL(ls->base), ls->scope); in ldapSearch()
1592 numEntries = ldap_count_entries(lc->ld, msg); in ldapSearch()
1613 for (m = ldap_first_entry(lc->ld, msg); m != 0; in ldapSearch()
1614 m = ldap_next_entry(lc->ld, m), numVals++) { in ldapSearch()
1625 nm = ldap_get_dn(lc->ld, m); in ldapSearch()
1636 for (nm = ldap_first_attribute(lc->ld, m, &ber); in ldapSearch()
1638 nm = ldap_next_attribute(lc->ld, m, ber)) { in ldapSearch()
1642 val = ldap_get_values_len(lc->ld, m, nm); in ldapSearch()
1681 stat = ldap_parse_result(lc->ld, msg, &lprEc, 0, 0, 0, in ldapSearch()
1684 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapSearch()
1698 stat = ldap_parse_virtuallist_control(lc->ld, in ldapSearch()
1702 index = targetPosP + lc->batchFrom; in ldapSearch()
1712 stat = ldap_parse_result(lc->ld, msg, &lprEc, 0, 0, 0, in ldapSearch()
1715 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapSearch()
1732 stat = ldap_parse_page_control(lc->ld, in ldapSearch()
1789 if (NULL != lc) { in ldapSearch()
1792 lc->doDis++; in ldapSearch()
1793 lc->doDel++; in ldapSearch()
1794 releaseCon(lc, stat); in ldapSearch()
1795 releaseLC(lc); in ldapSearch()
1798 releaseCon(lc, stat); in ldapSearch()
2043 ldapModifyObjectClass(__nis_ldap_conn_t **lc, char *dn, in ldapModifyObjectClass() argument
2154 msgid = ldap_modify((*lc)->ld, dn, mods); in ldapModifyObjectClass()
2156 tv = (*lc)->modifyTimeout; in ldapModifyObjectClass()
2157 stat = ldap_result((*lc)->ld, msgid, 0, &tv, &msg); in ldapModifyObjectClass()
2161 (void) ldap_get_option((*lc)->ld, in ldapModifyObjectClass()
2164 stat = ldap_parse_result((*lc)->ld, msg, &lderr, NULL, in ldapModifyObjectClass()
2168 stat = ldap_result2error((*lc)->ld, msg, 0); in ldapModifyObjectClass()
2171 (void) ldap_get_option((*lc)->ld, LDAP_OPT_ERROR_NUMBER, in ldapModifyObjectClass()
2176 releaseCon(*lc, stat); in ldapModifyObjectClass()
2180 *lc = findReferralCon(referralsp, &stat); in ldapModifyObjectClass()
2183 if (*lc == NULL) in ldapModifyObjectClass()
2185 msgid = ldap_modify((*lc)->ld, dn, mods); in ldapModifyObjectClass()
2187 (void) ldap_get_option((*lc)->ld, in ldapModifyObjectClass()
2191 stat = ldap_result((*lc)->ld, msgid, 0, &tv, &msg); in ldapModifyObjectClass()
2195 (void) ldap_get_option((*lc)->ld, in ldapModifyObjectClass()
2198 stat = ldap_parse_result((*lc)->ld, msg, &lderr, in ldapModifyObjectClass()
2226 __nis_ldap_conn_t *lc; in ldapModify() local
2237 if ((lc = findCon(&stat)) == 0) in ldapModify()
2243 msgid = ldap_delete(lc->ld, dn); in ldapModify()
2245 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapModify()
2249 tv = lc->deleteTimeout; in ldapModify()
2250 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapModify()
2255 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapModify()
2258 stat = ldap_parse_result(lc->ld, msg, &lderr, NULL, in ldapModify()
2265 releaseCon(lc, stat); in ldapModify()
2269 lc = findReferralCon(referralsp, &stat); in ldapModify()
2271 if (lc == NULL) in ldapModify()
2273 msgid = ldap_delete(lc->ld, dn); in ldapModify()
2275 (void) ldap_get_option(lc->ld, in ldapModify()
2279 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapModify()
2283 (void) ldap_get_option(lc->ld, in ldapModify()
2286 stat = ldap_parse_result(lc->ld, msg, &lderr, in ldapModify()
2297 stat = ldapAdd(dn, rv, objClassAttrs, lc); in ldapModify()
2298 lc = NULL; in ldapModify()
2301 if ((lc = findCon(&stat)) == 0) in ldapModify()
2315 msgid = ldap_modify(lc->ld, dn, mods); in ldapModify()
2317 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapModify()
2321 tv = lc->modifyTimeout; in ldapModify()
2322 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapModify()
2326 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapModify()
2329 stat = ldap_parse_result(lc->ld, msg, &lderr, NULL, in ldapModify()
2336 releaseCon(lc, stat); in ldapModify()
2340 lc = findReferralCon(referralsp, &stat); in ldapModify()
2343 if (lc == NULL) in ldapModify()
2345 msgid = ldap_modify(lc->ld, dn, mods); in ldapModify()
2347 (void) ldap_get_option(lc->ld, in ldapModify()
2351 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapModify()
2355 (void) ldap_get_option(lc->ld, in ldapModify()
2358 stat = ldap_parse_result(lc->ld, msg, &lderr, in ldapModify()
2376 stat = ldapModifyObjectClass(&lc, dn, rv, in ldapModify()
2480 stat = ldapAdd(dn, rv, objClassAttrs, lc); in ldapModify()
2481 lc = NULL; in ldapModify()
2492 lc != NULL ? lc->ld : 0, in ldapModify()
2493 lc != NULL ? NIL(lc->sp) : "nil", in ldapModify()
2497 releaseCon(lc, stat); in ldapModify()
2523 __nis_ldap_conn_t *lc = lcv; in ldapAdd() local
2529 releaseCon(lc, LDAP_SUCCESS); in ldapAdd()
2533 if (lc == 0) { in ldapAdd()
2534 if ((lc = findCon(&stat)) == 0) in ldapAdd()
2550 msgid = ldap_add(lc->ld, dn, mods); in ldapAdd()
2552 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &stat); in ldapAdd()
2555 tv = lc->addTimeout; in ldapAdd()
2556 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapAdd()
2560 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &stat); in ldapAdd()
2562 stat = ldap_parse_result(lc->ld, msg, &lderr, NULL, NULL, in ldapAdd()
2569 releaseCon(lc, stat); in ldapAdd()
2573 lc = findReferralCon(referralsp, &stat); in ldapAdd()
2575 if (lc == NULL) in ldapAdd()
2577 msgid = ldap_add(lc->ld, dn, mods); in ldapAdd()
2579 (void) ldap_get_option(lc->ld, in ldapAdd()
2583 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapAdd()
2587 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapAdd()
2590 stat = ldap_parse_result(lc->ld, msg, &lderr, NULL, in ldapAdd()
2601 lc != NULL ? lc->ld : 0, in ldapAdd()
2602 lc != NULL ? NIL(lc->sp) : "nil", in ldapAdd()
2606 releaseCon(lc, stat); in ldapAdd()
2621 __nis_ldap_conn_t *lc; in ldapChangeDN() local
2637 if ((lc = findCon(&stat)) == 0) in ldapChangeDN()
2642 releaseCon(lc, LDAP_SUCCESS); in ldapChangeDN()
2660 stat = ldap_rename(lc->ld, oldDn, rdn, NULL, 1, NULL, NULL, &msgid); in ldapChangeDN()
2663 tv = lc->modifyTimeout; in ldapChangeDN()
2664 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapChangeDN()
2668 (void) ldap_get_option(lc->ld, in ldapChangeDN()
2671 stat = ldap_parse_result(lc->ld, msg, &lderr, NULL, in ldapChangeDN()
2675 stat = ldap_result2error(lc->ld, msg, 0); in ldapChangeDN()
2678 (void) ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, in ldapChangeDN()
2683 releaseCon(lc, stat); in ldapChangeDN()
2687 lc = findReferralCon(referralsp, &stat); in ldapChangeDN()
2690 if (lc == NULL) in ldapChangeDN()
2692 msgid = ldap_rename(lc->ld, oldDn, rdn, NULL, 1, NULL, NULL, in ldapChangeDN()
2695 (void) ldap_get_option(lc->ld, in ldapChangeDN()
2699 stat = ldap_result(lc->ld, msgid, 0, &tv, &msg); in ldapChangeDN()
2703 (void) ldap_get_option(lc->ld, in ldapChangeDN()
2706 stat = ldap_parse_result(lc->ld, msg, &lderr, in ldapChangeDN()
2719 myself, lc == NULL ? 0: lc->ld, NIL(oldDn), NIL(rdn), in ldapChangeDN()
2723 myself, lc == NULL ? 0: lc->ld, NIL(oldDn), NIL(rdn), in ldapChangeDN()
2736 releaseCon(lc, stat); in ldapChangeDN()