summaryrefslogtreecommitdiff
path: root/res/res_timing_timerfd.c
diff options
context:
space:
mode:
authorWalter Doekes <walter+asterisk@wjd.nu>2015-07-02 11:57:44 +0200
committerWalter Doekes <walter+asterisk@wjd.nu>2015-07-02 12:10:22 +0200
commitf4dd9560cf6a50621172c34c2d9887041aaf8a3a (patch)
treedcb29ef92c2e3259db236b9adaf69ecbd7ab15f2 /res/res_timing_timerfd.c
parent69bfa518a02cbd69b364e5b0a500fc160e7b285d (diff)
res_timing: Don't close FD 0 when out of open files.
This fixes so a failure to get a timer file descriptor does not cascade to closing FD 0. On error, both res_timing_kqueue and res_timing_timerfd would call the destructor before setting the file handle. The file handle had been initialized to 0, causing FD 0 to be closed. This in turn, resulted in floods of "CLI>" messages and an unusable terminal. ASTERISK-19277 #close Reported by: Barry Chern For the 13 branch, this was already fixed. This patch only ensures that we do not attempt to close a negative file descriptor. Change-Id: I147d7e33726c6e5a2751928d56561494f5800350
Diffstat (limited to 'res/res_timing_timerfd.c')
-rw-r--r--res/res_timing_timerfd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/res/res_timing_timerfd.c b/res/res_timing_timerfd.c
index 6d5400bc3..43deb6ce7 100644
--- a/res/res_timing_timerfd.c
+++ b/res/res_timing_timerfd.c
@@ -76,8 +76,9 @@ struct timerfd_timer {
static void timer_destroy(void *obj)
{
struct timerfd_timer *timer = obj;
-
- close(timer->fd);
+ if (timer->fd > -1) {
+ close(timer->fd);
+ }
}
static void *timerfd_timer_open(void)