summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@dahyabhai.net>2012-01-11 19:30:06 -0500
committerNalin Dahyabhai <nalin@dahyabhai.net>2012-01-11 19:30:06 -0500
commit914642f65fcf35e48e77bd3c8ce377539af9045a (patch)
tree32e9179737cdefc7a3c9f68220399b87f6bbd706 /src
parent9743d79ec585494febdd2029b9094e948f09ac67 (diff)
downloadslapi-nis-914642f65fcf35e48e77bd3c8ce377539af9045a.tar.gz
slapi-nis-914642f65fcf35e48e77bd3c8ce377539af9045a.tar.xz
slapi-nis-914642f65fcf35e48e77bd3c8ce377539af9045a.zip
- avoid using pblocks for more than one internal operation - the server
allocates internal state each time but doesn't clean up any that's aready there if you reuse the block - correctly free values we use when constructing compat entries
Diffstat (limited to 'src')
-rw-r--r--src/back-nis.c2
-rw-r--r--src/back-sch.c4
-rw-r--r--src/back-shr.c34
-rw-r--r--src/format.c33
4 files changed, 31 insertions, 42 deletions
diff --git a/src/back-nis.c b/src/back-nis.c
index dbe81ce..c824312 100644
--- a/src/back-nis.c
+++ b/src/back-nis.c
@@ -909,6 +909,7 @@ backend_get_set_config(struct plugin_state *state,
NULL,
backend_get_set_config_entry_cb,
NULL);
+ slapi_pblock_destroy(pb);
defaults_get_map_config(map, &map_secure, &default_filter,
NULL, NULL, NULL, NULL, NULL);
if (cbdata.entry_filter == NULL) {
@@ -922,7 +923,6 @@ backend_get_set_config(struct plugin_state *state,
free(cbdata.entry_filter);
/* Clean up. */
- slapi_pblock_destroy(pb);
free(filter);
}
diff --git a/src/back-sch.c b/src/back-sch.c
index d114aed..3a91a74 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -403,7 +403,7 @@ backend_set_entry(Slapi_Entry *e, struct backend_set_data *data)
}
/* Clean up the values. */
for (j = 0; j < k; j++) {
- slapi_value_free(&value[k]);
+ slapi_value_free(&value[j]);
}
free(value);
}
@@ -666,6 +666,7 @@ backend_get_set_config(struct plugin_state *state,
NULL,
backend_get_set_config_entry_if_matching_cb,
NULL);
+ slapi_pblock_destroy(pb);
/* Return the results. */
*bases = cbdata.bases;
@@ -678,7 +679,6 @@ backend_get_set_config(struct plugin_state *state,
slapi_sdn_free(&setrdn);
}
slapi_sdn_free(&groupdn);
- slapi_pblock_destroy(pb);
}
/* Given an entry, return the filter which will match a container entry beneath
diff --git a/src/back-shr.c b/src/back-shr.c
index 3ab417d..003a728 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -381,7 +381,6 @@ backend_shr_set_config_entry_add(struct plugin_state *state, Slapi_Entry *e,
char **set_bases;
char *set_entry_filter;
- pb = slapi_pblock_new();
flag = FALSE;
backend_set_config_read_config(state, e, group, set, &flag, &set_data);
if (set_data == NULL) {
@@ -389,7 +388,6 @@ backend_shr_set_config_entry_add(struct plugin_state *state, Slapi_Entry *e,
state->plugin_desc->spd_id,
"incomplete definition for %s in %s (2)\n",
set, group);
- slapi_pblock_destroy(pb);
return 0;
}
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -408,6 +406,7 @@ backend_shr_set_config_entry_add(struct plugin_state *state, Slapi_Entry *e,
state->plugin_desc->spd_id,
"searching '%s' for '%s'\n",
set_bases[i], set_entry_filter);
+ pb = slapi_pblock_new();
slapi_search_internal_set_pb(pb,
set_bases[i],
LDAP_SCOPE_SUBTREE,
@@ -421,11 +420,11 @@ backend_shr_set_config_entry_add(struct plugin_state *state, Slapi_Entry *e,
NULL,
backend_shr_set_entry_cb,
NULL);
+ slapi_pblock_destroy(pb);
}
/* Warn if we didn't put anything into the set. */
backend_check_empty(state, set_data->group, set_data->set);
/* Clean up. */
- slapi_pblock_destroy(pb);
return 0;
}
@@ -559,11 +558,11 @@ backend_shr_startup(struct plugin_state *state, const char *filter)
backend_update_params(state);
- pb = slapi_pblock_new();
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"searching under \"%s\" for configuration\n",
state->plugin_base);
+ pb = slapi_pblock_new();
slapi_search_internal_set_pb(pb,
state->plugin_base,
LDAP_SCOPE_ONELEVEL,
@@ -834,7 +833,6 @@ backend_shr_mods_as_string(LDAPMod **mods)
/* Update any entries in the map for which the passed-in entry will affect the
* values which are derived. */
struct backend_shr_update_references_cbdata {
- Slapi_PBlock *pb;
Slapi_Entry *e;
LDAPMod **mods;
};
@@ -855,6 +853,7 @@ backend_shr_update_references_cb(const char *group, const char *set,
Slapi_ValueSet *values;
Slapi_Value *value;
Slapi_Filter *next_filter;
+ Slapi_PBlock *pb;
char **ref_attrs, *actual_attr, *filter, **set_bases;
char *these_attrs[2], *prev_attrs[2], *next_attrs[2];
const char *these_filter, *prev_filter, *next_filter_str;
@@ -924,7 +923,8 @@ backend_shr_update_references_cb(const char *group, const char *set,
for (i = 0;
(set_bases != NULL) && (set_bases[i] != NULL);
i++) {
- slapi_search_internal_set_pb(cbdata->pb,
+ pb = slapi_pblock_new();
+ slapi_search_internal_set_pb(pb,
set_bases[i],
LDAP_SCOPE_SUBTREE,
filter,
@@ -933,10 +933,11 @@ backend_shr_update_references_cb(const char *group, const char *set,
NULL,
state->plugin_identity,
0);
- slapi_search_internal_callback_pb(cbdata->pb, set_data,
+ slapi_search_internal_callback_pb(pb, set_data,
NULL,
backend_shr_set_entry_cb,
NULL);
+ slapi_pblock_destroy(pb);
}
free(filter);
}
@@ -1082,7 +1083,8 @@ backend_shr_update_references_cb(const char *group, const char *set,
"with scope %d\n",
slapi_sdn_get_ndn(these_bases[l]),
filter, scope);
- slapi_search_internal_set_pb(cbdata->pb,
+ pb = slapi_pblock_new();
+ slapi_search_internal_set_pb(pb,
slapi_sdn_get_ndn(these_bases[l]),
scope,
filter,
@@ -1095,11 +1097,12 @@ backend_shr_update_references_cb(const char *group, const char *set,
note_cbdata.state = state;
note_cbdata.sdn_list = &these_entries;
note_cbdata.sdn_list2 = &these_entries2;
- slapi_search_internal_callback_pb(cbdata->pb,
+ slapi_search_internal_callback_pb(pb,
&note_cbdata,
NULL,
backend_shr_note_entry_sdn_cb,
NULL);
+ slapi_pblock_destroy(pb);
}
free(filter);
/* Search for entries in the previous link in
@@ -1121,7 +1124,8 @@ backend_shr_update_references_cb(const char *group, const char *set,
"scope %d\n",
slapi_sdn_get_ndn(prev_bases[l]),
filter, scope);
- slapi_search_internal_set_pb(cbdata->pb,
+ pb = slapi_pblock_new();
+ slapi_search_internal_set_pb(pb,
slapi_sdn_get_ndn(prev_bases[l]),
scope,
filter,
@@ -1134,11 +1138,12 @@ backend_shr_update_references_cb(const char *group, const char *set,
note_cbdata.state = state;
note_cbdata.sdn_list = &prev_entries;
note_cbdata.sdn_list2 = &prev_entries2;
- slapi_search_internal_callback_pb(cbdata->pb,
+ slapi_search_internal_callback_pb(pb,
&note_cbdata,
NULL,
backend_shr_note_entry_sdn_cb,
NULL);
+ slapi_pblock_destroy(pb);
}
free(filter);
}
@@ -1257,8 +1262,9 @@ backend_shr_update_references_cb(const char *group, const char *set,
slapi_sdn_get_ndn(these_entries[k]));
continue;
}
+ pb = slapi_pblock_new();
if ((next_filter != NULL) &&
- (slapi_filter_test(cbdata->pb, this_entry,
+ (slapi_filter_test(pb, this_entry,
next_filter, 0) != 0)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
@@ -1267,8 +1273,10 @@ backend_shr_update_references_cb(const char *group, const char *set,
slapi_sdn_get_ndn(these_entries[k]),
next_filter_str);
slapi_entry_free(this_entry);
+ slapi_pblock_destroy(pb);
continue;
}
+ slapi_pblock_destroy(pb);
if (slapi_vattr_values_get(this_entry,
these_attrs[0],
&values,
@@ -1406,7 +1414,6 @@ backend_shr_update_references(struct plugin_state *state, Slapi_Entry *e,
{
struct backend_shr_update_references_cbdata cbdata;
cbdata.e = e;
- cbdata.pb = slapi_pblock_new();
cbdata.mods = mods;
if (!map_data_foreach_map(state, NULL,
backend_shr_update_references_cb, &cbdata)) {
@@ -1415,7 +1422,6 @@ backend_shr_update_references(struct plugin_state *state, Slapi_Entry *e,
"error updating references for \"%s\"\n",
slapi_entry_get_ndn(cbdata.e));
}
- slapi_pblock_destroy(cbdata.pb);
}
/* Add any map entries which correspond to a directory server entry in this
diff --git a/src/format.c b/src/format.c
index 9f5b214..ba09b41 100644
--- a/src/format.c
+++ b/src/format.c
@@ -1578,13 +1578,6 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
attr = argv[2];
/* Set up to search for matches. */
- local_pb = slapi_pblock_new();
- if (local_pb == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
- "referred: out of memory\n");
- format_free_parsed_args(argv);
- return -ENOMEM;
- }
cbdata.state = state;
cbdata.attr = attr;
cbdata.choices = NULL;
@@ -1601,7 +1594,6 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
"no search bases defined for \"%s\"/\"%s\"?\n",
group, other_set);
backend_free_set_config(set_bases, set_filter);
- slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return -ENOENT;
}
@@ -1626,7 +1618,6 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
state->plugin_desc->spd_id,
"referred: out of memory\n");
backend_free_set_config(set_bases, set_filter);
- slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return -ENOMEM;
}
@@ -1638,7 +1629,6 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
"referred: out of memory\n");
free(tndn);
backend_free_set_config(set_bases, set_filter);
- slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return -ENOMEM;
}
@@ -1650,6 +1640,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
attrs[1] = NULL;
for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) {
/* Set up the search. */
+ local_pb = slapi_pblock_new();
slapi_search_internal_set_pb(local_pb,
set_bases[i], LDAP_SCOPE_SUBTREE,
filter, attrs, FALSE,
@@ -1664,11 +1655,11 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
NULL,
format_referred_entry_cb,
NULL);
+ slapi_pblock_destroy(local_pb);
}
free(filter);
backend_free_set_config(set_bases, set_filter);
- slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
/* Return any values we found. */
@@ -1834,15 +1825,6 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
attr_links, NULL);
free(attr_links);
- /* Set up to search for referrers. */
- local_pb = slapi_pblock_new();
- if (local_pb == NULL) {
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
- "referred_r: out of memory\n");
- format_free_parsed_args(argv);
- return -ENOMEM;
- }
-
/* Get the searching parameters for the set which contains the entry,
* and all of the referred-to sets, and save them for use at the last
* link in the chain. */
@@ -1914,6 +1896,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
"referred_r: searching under %s"
" for \"%s\" (link=1.%d)\n",
ndn, filter, i);
+ local_pb = slapi_pblock_new();
slapi_search_internal_set_pb(local_pb,
ndn,
LDAP_SCOPE_SUBTREE,
@@ -1932,6 +1915,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
NULL,
format_referred_r_entry_cb,
NULL);
+ slapi_pblock_destroy(local_pb);
}
free(filter);
/* Walk the set of search bases for the next link. */
@@ -1953,6 +1937,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
"referred_r: searching under %s"
" for \"%s\" (link=2.%d)\n",
ndn, filter, i);
+ local_pb = slapi_pblock_new();
slapi_search_internal_set_pb(local_pb,
ndn,
LDAP_SCOPE_SUBTREE,
@@ -1971,6 +1956,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
NULL,
format_referred_r_entry_cb,
NULL);
+ slapi_pblock_destroy(local_pb);
}
free(filter);
free(tndn);
@@ -1984,7 +1970,6 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
}
format_free_sdn_list(these_entries, these_entries2);
- slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
/* Return any values we found. */
@@ -3852,7 +3837,6 @@ format_format(struct plugin_state *state, Slapi_Entry *e,
spd_id = state->plugin_desc->spd_id;
buflen = DEFAULT_BUFFER_SIZE;
- pb = slapi_pblock_new();
do {
buf = malloc(buflen);
if (buf == NULL) {
@@ -3862,15 +3846,16 @@ format_format(struct plugin_state *state, Slapi_Entry *e,
"for \"%s\" failing: out of memory\n",
fmt,
slapi_entry_get_ndn(e));
- slapi_pblock_destroy(pb);
return NULL;
}
+ pb = slapi_pblock_new();
i = format_expand(state, pb, e, group, set,
fmt, disallowed,
buf, buflen, choices,
rel_attrs, ref_attrs, inref_attrs,
ref_attr_list, inref_attr_list);
+ slapi_pblock_destroy(pb);
if ((i >= 0) && (i < buflen)) {
buf[i] = '\0';
ret = xmemdup(buf, i);
@@ -3913,8 +3898,6 @@ format_format(struct plugin_state *state, Slapi_Entry *e,
free(buf);
} while (i == -ENOBUFS);
- slapi_pblock_destroy(pb);
-
return ret;
}