Index: res/res_timing_timerfd.c =================================================================== --- res/res_timing_timerfd.c (revision 313432) +++ res/res_timing_timerfd.c (working copy) @@ -162,6 +162,20 @@ uint64_t expirations; int read_result = 0; + struct timerfd_timer *our_timer, find_helper = { + .handle = handle, + }; + + if (!(our_timer = ao2_find(timerfd_timers, &find_helper, OBJ_POINTER))) { + ast_log(LOG_ERROR, "Couldn't find timer with handle %d\n", handle); + return; + } + + if (our_timer->saved_timer.it_value.tv_nsec == 0L) { + ast_log(LOG_WARNING, "Reading attempt on idle timerfd. This would have caused a deadlock.\n"); + return; + } + do { read_result = read(handle, &expirations, sizeof(expirations)); if (read_result == -1) {