summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorzmq810150896 <[email protected]>2023-12-21 11:17:59 +0800
committerGitHub <[email protected]>2023-12-21 11:17:59 +0800
commitcdad0c254ad9a9207c32313f9dd8b50e500fed65 (patch)
tree4368c9554ebd0636297aa119d6522d0a79b00055 /components
parent3dfafcd1d982c09b1718f36c956263fd1ef507db (diff)
Update epoll and timerfd (#8330)
Diffstat (limited to 'components')
-rw-r--r--components/libc/posix/io/timerfd/timerfd.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/components/libc/posix/io/timerfd/timerfd.c b/components/libc/posix/io/timerfd/timerfd.c
index 636f00f498..19f86e48cc 100644
--- a/components/libc/posix/io/timerfd/timerfd.c
+++ b/components/libc/posix/io/timerfd/timerfd.c
@@ -14,6 +14,10 @@
#include <poll.h>
#include <sys/timerfd.h>
+#define DBG_TAG "TIMERFD"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
#define INIT_PERIODIC 0
#define OPEN_PERIODIC 1
#define ENTER_PERIODIC 2
@@ -164,7 +168,7 @@ static ssize_t timerfd_read(struct dfs_file *file, void *buf, size_t count, off_
}
(*buffer) = rt_atomic_load(&(tfd->timeout_num));
-
+ rt_atomic_store(&(tfd->timeout_num), 0);
rt_atomic_store(&(tfd->ticks), 0);
}
@@ -325,7 +329,13 @@ static void timerfd_timeout(void *parameter)
tfd->timer = rt_timer_create(TIMERFD_MUTEX_NAME, timerfd_timeout,
tfd, tfd->tick_out,
RT_TIMER_FLAG_PERIODIC | RT_TIMER_FLAG_SOFT_TIMER);
- RT_ASSERT(tfd->timer);
+
+ if (tfd->timer == RT_NULL)
+ {
+ LOG_E("rt_timer_create fail \n");
+ rt_mutex_release(&tfd->lock);
+ return ;
+ }
rt_timer_start(tfd->timer);
}
@@ -458,7 +468,12 @@ static int timerfd_do_settime(int fd, int flags, const struct itimerspec *new, s
tfd->timer = rt_timer_create(TIMERFD_MUTEX_NAME, timerfd_timeout,
tfd, tick_out,
RT_TIMER_FLAG_ONE_SHOT | RT_TIMER_FLAG_SOFT_TIMER);
- RT_ASSERT(tfd->timer);
+ if (tfd->timer == RT_NULL)
+ {
+ LOG_E("rt_timer_create fail \n");
+ rt_mutex_release(&tfd->lock);
+ return -ENOMEM;
+ }
rt_timer_start(tfd->timer);
}
else