summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@dahyabhai.net>2013-07-22 15:56:08 -0400
committerNalin Dahyabhai <nalin@dahyabhai.net>2013-08-07 14:46:03 -0400
commitfd7b409d26b1dcef3ff0ca6bc50b736fad6184b2 (patch)
tree9a2db6e3b49635665c47764bfdab9b837b6e17dc /src
parentf906d30fd05483acfe1c816f91bfd8ff9410897b (diff)
downloadslapi-nis-fd7b409d26b1dcef3ff0ca6bc50b736fad6184b2.tar.gz
slapi-nis-fd7b409d26b1dcef3ff0ca6bc50b736fad6184b2.tar.xz
slapi-nis-fd7b409d26b1dcef3ff0ca6bc50b736fad6184b2.zip
Notice when we fail to write lock
When we fail to write-lock our cache, cancel our update attempt. We'll fall out of sync with the real data, but for now at least, that's better than completely hosing the cache by updating it without the lock.
Diffstat (limited to 'src')
-rw-r--r--src/back-shr.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/back-shr.c b/src/back-shr.c
index ade1336..5b7c6ec 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -594,7 +594,14 @@ backend_shr_startup(struct plugin_state *state,
NULL,
state->plugin_identity,
0);
- map_wrlock();
+ if (map_wrlock() != 0) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ state->plugin_desc->spd_id,
+ "failed to search under \"%s\" for "
+ "configuration: failed to acquire a lock\n",
+ state->plugin_base);
+ goto done_with_lock;
+ }
set_cbdata.state = state;
set_cbdata.pb = pb;
slapi_search_internal_callback_pb(pb, &set_cbdata,
@@ -602,6 +609,7 @@ backend_shr_startup(struct plugin_state *state,
backend_set_config_entry_add_cb,
NULL);
map_unlock();
+done_with_lock:
slapi_pblock_destroy(pb);
}
@@ -1582,7 +1590,14 @@ backend_shr_add_cb(Slapi_PBlock *pb)
/* Add map entries which corresponded to this directory server
* entry. */
wrap_inc_call_level();
- map_wrlock();
+ if (map_wrlock() != 0) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "error adding set entries corresponding to "
+ "\"%s\": failed to acquire a lock\n",
+ cbdata.ndn);
+ goto done_with_lock;
+ }
if (!map_data_foreach_map(cbdata.state, NULL,
backend_shr_add_entry_cb, &cbdata)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -1604,8 +1619,8 @@ backend_shr_add_cb(Slapi_PBlock *pb)
/* Update entries in maps which are affected by this entry. */
backend_shr_update_references(cbdata.state, pb, cbdata.e, NULL, NULL);
-
map_unlock();
+done_with_lock:
wrap_dec_call_level();
return 0;
}
@@ -2009,7 +2024,14 @@ backend_shr_modify_cb(Slapi_PBlock *pb)
/* Modify map entries which corresponded to this directory server
* entry. */
wrap_inc_call_level();
- map_wrlock();
+ if (map_wrlock() != 0) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "error modifying set entries corresponding to "
+ "\"%s\": failed to acquire a lock\n",
+ cbdata.ndn);
+ goto done_with_lock;
+ }
if (!map_data_foreach_map(cbdata.state, NULL,
backend_shr_modify_entry_cb, &cbdata)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -2059,6 +2081,7 @@ backend_shr_modify_cb(Slapi_PBlock *pb)
slapi_sdn_free(&sdn);
}
map_unlock();
+done_with_lock:
wrap_dec_call_level();
free(cbdata.modlist);
return 0;
@@ -2178,7 +2201,14 @@ backend_shr_modrdn_cb(Slapi_PBlock *pb)
/* Modify map entries which corresponded to this directory server
* entry. */
wrap_inc_call_level();
- map_wrlock();
+ if (map_wrlock() != 0) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "error renaming map entries corresponding to "
+ "\"%s\": failed to acquire a lock\n",
+ cbdata.ndn_post);
+ goto done_with_lock;
+ }
if (!map_data_foreach_map(cbdata.state, NULL,
backend_shr_modrdn_entry_cb, &cbdata)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -2205,6 +2235,7 @@ backend_shr_modrdn_cb(Slapi_PBlock *pb)
backend_set_config_entry_add_cb(cbdata.e_post, &set_cbdata);
}
map_unlock();
+done_with_lock:
wrap_dec_call_level();
return 0;
}
@@ -2305,7 +2336,14 @@ backend_shr_delete_cb(Slapi_PBlock *pb)
/* Remove map entries which corresponded to this directory server
* entry. */
wrap_inc_call_level();
- map_wrlock();
+ if (map_wrlock() != 0) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "error removing entries corresponding to "
+ "\"%s\": failed to acquire a lock\n",
+ cbdata.ndn);
+ goto done_with_lock;
+ }
if (!map_data_foreach_map(cbdata.state, NULL,
backend_shr_delete_entry_cb, &cbdata)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -2324,6 +2362,7 @@ backend_shr_delete_cb(Slapi_PBlock *pb)
* affected by this entry. */
backend_shr_update_references(cbdata.state, pb, cbdata.e, NULL, NULL);
map_unlock();
+done_with_lock:
wrap_dec_call_level();
return 0;
}