summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--evthread-internal.h5
-rw-r--r--evthread.c19
2 files changed, 18 insertions, 6 deletions
diff --git a/evthread-internal.h b/evthread-internal.h
index 346b2bb9..45e178f2 100644
--- a/evthread-internal.h
+++ b/evthread-internal.h
@@ -376,6 +376,11 @@ int evsig_global_setup_locks_(const int enable_locks);
int evutil_global_setup_locks_(const int enable_locks);
int evutil_secure_rng_global_setup_locks_(const int enable_locks);
+/** Return current evthread_lock_callbacks */
+struct evthread_lock_callbacks *evthread_get_lock_callbacks();
+/** Return current evthread_condition_callbacks */
+struct evthread_condition_callbacks *evthread_get_condition_callbacks();
+
#endif
#ifdef __cplusplus
diff --git a/evthread.c b/evthread.c
index 4da5d24e..40933626 100644
--- a/evthread.c
+++ b/evthread.c
@@ -69,12 +69,21 @@ evthread_set_id_callback(unsigned long (*id_fn)(void))
evthread_id_fn_ = id_fn;
}
+struct evthread_lock_callbacks *evthread_get_lock_callbacks()
+{
+ return evthread_lock_debugging_enabled_
+ ? &original_lock_fns_ : &evthread_lock_fns_;
+}
+struct evthread_condition_callbacks *evthread_get_condition_callbacks()
+{
+ return evthread_lock_debugging_enabled_
+ ? &original_cond_fns_ : &evthread_cond_fns_;
+}
+
int
evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs)
{
- struct evthread_lock_callbacks *target =
- evthread_lock_debugging_enabled_
- ? &original_lock_fns_ : &evthread_lock_fns_;
+ struct evthread_lock_callbacks *target = evthread_get_lock_callbacks();
if (!cbs) {
if (target->alloc)
@@ -109,9 +118,7 @@ evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs)
int
evthread_set_condition_callbacks(const struct evthread_condition_callbacks *cbs)
{
- struct evthread_condition_callbacks *target =
- evthread_lock_debugging_enabled_
- ? &original_cond_fns_ : &evthread_cond_fns_;
+ struct evthread_condition_callbacks *target = evthread_get_condition_callbacks();
if (!cbs) {
if (target->alloc_condition)