aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/select.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/select.c b/src/select.c
index 0b115c61..b594ca55 100644
--- a/src/select.c
+++ b/src/select.c
@@ -324,11 +324,18 @@ int osmo_timerfd_setup(struct osmo_fd *ofd, int (*cb)(struct osmo_fd *, unsigned
ofd->when = BSC_FD_READ;
if (ofd->fd < 0) {
+ int rc;
+
ofd->fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
if (ofd->fd < 0)
return ofd->fd;
- osmo_fd_register(ofd);
+ rc = osmo_fd_register(ofd);
+ if (rc < 0) {
+ close(ofd->fd);
+ ofd->fd = -1;
+ return rc;
+ }
}
return 0;
}