From dac653d6940824eadf2ccc5d09d26697ca4f61e9 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sun, 5 Oct 2025 09:44:24 +0800 Subject: [PATCH] IOEventCallback: change event type from short to int --- HISTORY | 3 ++- src/fast_task_queue.h | 10 +++------- src/fast_timer.c | 1 + src/ioevent.h | 2 +- src/ioevent_loop.c | 12 ++++++++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/HISTORY b/HISTORY index 59444cf..c2f6a4f 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,8 @@ -Version 1.81 2025-10-03 +Version 1.81 2025-10-05 * support Linux io_uring * free_queue support parameter: need_shrink and set task->shrinked + * IOEventCallback: change event type from short to int Version 1.80 2025-09-10 * getIpaddrByNameEx: IPv4 has priority over IPv6 diff --git a/src/fast_task_queue.h b/src/fast_task_queue.h index 5f5f6ff..3234358 100644 --- a/src/fast_task_queue.h +++ b/src/fast_task_queue.h @@ -42,7 +42,7 @@ typedef void (*TaskCleanUpCallback) (struct fast_task_info *task); typedef int (*TaskInitCallback)(struct fast_task_info *task, void *arg); typedef void (*TaskReleaseCallback)(struct fast_task_info *task); -typedef void (*IOEventCallback) (int sock, short event, void *arg); +typedef void (*IOEventCallback) (int sock, const int event, void *arg); typedef int (*TaskContinueCallback)(struct fast_task_info *task); struct sf_network_handler; @@ -57,9 +57,7 @@ typedef struct ioevent_entry { FastTimerEntry timer; //must first int fd; -#if IOEVENT_USE_URING - int res; -#endif + int res; //just for io_uring, since v1.0.81 IOEventCallback callback; } IOEventEntry; @@ -128,12 +126,10 @@ struct fast_task_info uint16_t port; //peer port -#if IOEVENT_USE_URING struct { int8_t is_client; uint8_t op_type; - } uring; //since v1.0.81 -#endif + } uring; //just for io_uring, since v1.0.81 struct { uint8_t current; diff --git a/src/fast_timer.c b/src/fast_timer.c index 73bfb5b..53cb666 100644 --- a/src/fast_timer.c +++ b/src/fast_timer.c @@ -185,6 +185,7 @@ int fast_timer_timeouts_get(FastTimer *timer, const int64_t current_time, } else { last->rehash = false; } + continue; } } else { //expired diff --git a/src/ioevent.h b/src/ioevent.h index 37741f8..b82efae 100644 --- a/src/ioevent.h +++ b/src/ioevent.h @@ -22,7 +22,7 @@ #include "_os_define.h" #include "logger.h" -#define IOEVENT_TIMEOUT 0x8000 +#define IOEVENT_TIMEOUT (1 << 20) #if IOEVENT_USE_EPOLL #include diff --git a/src/ioevent_loop.c b/src/ioevent_loop.c index 3695cad..60a0a9d 100644 --- a/src/ioevent_loop.c +++ b/src/ioevent_loop.c @@ -65,7 +65,7 @@ static int ioevent_process(IOEventPoller *ioevent) } } else { logWarning("file: "__FILE__", line: %d, " - "unexpected flags: %d, result: %u", __LINE__, + "io_uring unexpected flags: %d, result: %d", __LINE__, ioevent->cqe->flags, ioevent->cqe->res); } } @@ -287,9 +287,13 @@ int ioevent_set(struct fast_task_info *task, struct nio_thread_data *pThread, return result; } } else { - logInfo("file: "__FILE__", line: %d, " - "skip uring_prep_recv, fd: %d, port: %d, in progress op type: %d, timeout: %"PRId64, - __LINE__, sock, task->port, FC_URING_OP_TYPE(task), task->event.timer.expires); + /* + logWarning("file: "__FILE__", line: %d, " + "skip uring_prep_recv, fd: %d, port: %d, " + "in progress op type: %d, timeout: %"PRId64, + __LINE__, sock, task->port, FC_URING_OP_TYPE(task), + task->event.timer.expires); + */ } } else { #endif