1 Distinguish between contexts that are somewhat persistent and one-offs
2 which are used to fulfill part of a larger request. Proposed for #322.
4 diff -up nss_ldap-265/ldap-grp.c nss_ldap-265/ldap-grp.c
5 --- nss_ldap-265/ldap-grp.c 2010-01-08 17:38:38.000000000 -0500
6 +++ nss_ldap-265/ldap-grp.c 2010-01-08 17:38:38.000000000 -0500
7 @@ -859,7 +859,7 @@ ng_chase (const char *dn, ldap_initgroup
9 LA_TYPE (a) = LA_TYPE_STRING;
11 - if (_nss_ldap_ent_context_init_locked (&ctx) == NULL)
12 + if (_nss_ldap_ent_context_init_internal_locked (&ctx) == NULL)
16 @@ -931,7 +931,7 @@ ng_chase_backlink (const char ** members
17 LA_STRING_LIST (a) = filteredMembersOf;
18 LA_TYPE (a) = LA_TYPE_STRING_LIST_OR;
20 - if (_nss_ldap_ent_context_init_locked (&ctx) == NULL)
21 + if (_nss_ldap_ent_context_init_internal_locked (&ctx) == NULL)
23 free (filteredMembersOf);
25 diff -up nss_ldap-265/ldap-netgrp.c nss_ldap-265/ldap-netgrp.c
26 --- nss_ldap-265/ldap-netgrp.c 2009-11-06 05:28:08.000000000 -0500
27 +++ nss_ldap-265/ldap-netgrp.c 2010-01-08 17:38:38.000000000 -0500
28 @@ -691,7 +691,7 @@ do_innetgr_nested (ldap_innetgr_args_t *
29 LA_TYPE (a) = LA_TYPE_STRING;
30 LA_STRING (a) = nested; /* memberNisNetgroup */
32 - if (_nss_ldap_ent_context_init_locked (&ctx) == NULL)
33 + if (_nss_ldap_ent_context_init_internal_locked (&ctx) == NULL)
35 debug ("<== do_innetgr_nested: failed to initialize context");
37 diff -up nss_ldap-265/ldap-nss.c nss_ldap-265/ldap-nss.c
38 --- nss_ldap-265/ldap-nss.c 2010-01-08 17:38:38.000000000 -0500
39 +++ nss_ldap-265/ldap-nss.c 2010-01-08 17:40:37.000000000 -0500
40 @@ -2043,6 +2043,7 @@ _nss_ldap_ent_context_init_locked (ent_c
41 debug ("<== _nss_ldap_ent_context_init_locked");
44 + ctx->ec_internal = 0;
48 @@ -2104,7 +2105,8 @@ do_context_release (ent_context_t * ctx,
50 LS_INIT (ctx->ec_state);
52 - if (_nss_ldap_test_config_flag (NSS_LDAP_FLAGS_CONNECT_POLICY_ONESHOT))
53 + if (!ctx->ec_internal &&
54 + _nss_ldap_test_config_flag (NSS_LDAP_FLAGS_CONNECT_POLICY_ONESHOT))
58 @@ -2113,6 +2115,16 @@ do_context_release (ent_context_t * ctx,
63 +_nss_ldap_ent_context_init_internal_locked (ent_context_t ** pctx)
66 + ctx = _nss_ldap_ent_context_init_locked (pctx);
68 + ctx->ec_internal = 1;
73 * Clears a given context; we require the caller
74 * to acquire the lock.
75 diff -up nss_ldap-265/ldap-nss.h nss_ldap-265/ldap-nss.h
76 --- nss_ldap-265/ldap-nss.h 2010-01-08 17:38:38.000000000 -0500
77 +++ nss_ldap-265/ldap-nss.h 2010-01-08 17:42:34.000000000 -0500
78 @@ -574,6 +574,8 @@ struct ent_context
79 ldap_state_t ec_state; /* eg. for services */
80 int ec_msgid; /* message ID */
81 LDAPMessage *ec_res; /* result chain */
82 + int ec_internal; /* this context is just a part of a larger
83 + * query for information */
84 ldap_service_search_descriptor_t *ec_sd; /* current sd */
85 struct berval *ec_cookie; /* cookie for paged searches */
86 int ec_eof; /* reached notional end of file */
87 @@ -769,6 +771,15 @@ ent_context_t *_nss_ldap_ent_context_ini
88 ent_context_t *_nss_ldap_ent_context_init_locked (ent_context_t **);
91 + * _nss_ldap_ent_context_init_internal_locked() has the same
92 + * behaviour, except it marks the context as one that's being
93 + * used to fetch additional data used in answering a request, i.e.
94 + * that this isn't the "main" context
97 +ent_context_t *_nss_ldap_ent_context_init_internal_locked (ent_context_t **);
100 * _nss_ldap_ent_context_release() is used to manually free a context
102 void _nss_ldap_ent_context_release (ent_context_t **);