diff options
author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-12-02 17:54:05 -0500 |
---|---|---|
committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-12-02 17:54:05 -0500 |
commit | 0599ac42ec109e944e2cd914764258a7acd2652f (patch) | |
tree | d6d7e592450d05b1663d01db9d5863daea8c23d5 /src/back-sch.c | |
parent | 28b315770bf6f40cd1f55afcef8f61b47a3eef42 (diff) | |
download | slapi-nis-0599ac42ec109e944e2cd914764258a7acd2652f.tar.gz slapi-nis-0599ac42ec109e944e2cd914764258a7acd2652f.tar.xz slapi-nis-0599ac42ec109e944e2cd914764258a7acd2652f.zip |
- use a counter to make sure we don't recurse inside the same thread,
which might cause us to try to take a read lock when we're holding the
write lock, or vice-versa
Diffstat (limited to 'src/back-sch.c')
-rw-r--r-- | src/back-sch.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/back-sch.c b/src/back-sch.c index ef69aba..8a6486f 100644 --- a/src/back-sch.c +++ b/src/back-sch.c @@ -811,16 +811,9 @@ static int backend_search_cb(Slapi_PBlock *pb) { struct backend_search_cbdata cbdata; -#if 0 - Slapi_Operation *op; - /* If we were called to service an internal search (made by us or any - * other plugin), stop right here. */ - op = NULL; - slapi_pblock_get(pb, SLAPI_OPERATION, &op); - if (slapi_operation_is_flag_set(op, OP_FLAG_INTERNAL)) { + if (wrap_get_call_level() > 0) { return 0; } -#endif memset(&cbdata, 0, sizeof(cbdata)); cbdata.pb = pb; slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &cbdata.state); @@ -838,25 +831,17 @@ backend_search_cb(Slapi_PBlock *pb) cbdata.closest_match = NULL; cbdata.text = NULL; cbdata.n_entries = 0; - /* If we were called to service one of our internal searches, stop - * right here. */ - if (backend_shr_is_caller(cbdata.state, cbdata.pb)) { - slapi_log_error(SLAPI_LOG_PLUGIN, - cbdata.state->plugin_desc->spd_id, - "ignoring self-started search from \"%s\" for " - "\"%s\" with scope %d\n", - cbdata.target, cbdata.strfilter, cbdata.scope); - return 0; - } /* Okay, we can search. */ slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "searching from \"%s\" for \"%s\" with scope %d\n", cbdata.target, cbdata.strfilter, cbdata.scope); cbdata.target_dn = slapi_sdn_new_dn_byval(cbdata.target); /* Walk the list of groups. */ + wrap_inc_call_level(); map_rdlock(); map_data_foreach_domain(cbdata.state, backend_search_group_cb, &cbdata); map_unlock(); + wrap_dec_call_level(); /* If we "own" the search target DN, then we need to send a response. */ if (cbdata.answer) { if (cbdata.matched || (cbdata.n_entries > 0)) { @@ -999,6 +984,12 @@ static int backend_write_cb(Slapi_PBlock *pb) { int ret; + + if (wrap_get_call_level() > 0) { + return 0; + } + + wrap_inc_call_level(); map_rdlock(); if (backend_check_scope_pb(pb)) { slapi_send_ldap_result(pb, LDAP_INSUFFICIENT_ACCESS, @@ -1008,6 +999,8 @@ backend_write_cb(Slapi_PBlock *pb) ret = 0; } map_unlock(); + wrap_dec_call_level(); + return ret; } @@ -1020,6 +1013,11 @@ backend_bind_cb(Slapi_PBlock *pb) struct berval *urls[] = {&ref, NULL}; const char *ndn; + if (wrap_get_call_level() > 0) { + return 0; + } + + wrap_inc_call_level(); map_rdlock(); backend_locate(pb, &data); if (data != NULL) { @@ -1046,6 +1044,7 @@ backend_bind_cb(Slapi_PBlock *pb) } } map_unlock(); + wrap_dec_call_level(); return ret; } @@ -1053,6 +1052,10 @@ static int backend_compare_cb(Slapi_PBlock *pb) { int ret; + if (wrap_get_call_level() > 0) { + return 0; + } + wrap_inc_call_level(); map_rdlock(); if (backend_check_scope_pb(pb)) { slapi_send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, @@ -1062,6 +1065,7 @@ backend_compare_cb(Slapi_PBlock *pb) ret = 0; } map_unlock(); + wrap_dec_call_level(); return ret; } |