struct ioevent_puller add field service_name

use_iouring
YuQing 2025-10-06 20:53:14 +08:00
parent dac653d694
commit de80dc19dc
5 changed files with 21 additions and 11 deletions

View File

@ -105,6 +105,7 @@ int fast_timer_modify(FastTimer *timer, FastTimerEntry *entry,
if ((result=fast_timer_remove(timer, entry)) == 0) { if ((result=fast_timer_remove(timer, entry)) == 0) {
fast_timer_add_ex(timer, entry, new_expires, true); fast_timer_add_ex(timer, entry, new_expires, true);
} }
return result; return result;
} }
return 0; return 0;

View File

@ -45,8 +45,8 @@ int kqueue_ev_convert(int16_t event, uint16_t flags)
} }
#endif #endif
int ioevent_init(IOEventPoller *ioevent, const int size, int ioevent_init(IOEventPoller *ioevent, const char *service_name,
const int timeout_ms, const int extra_events) const int size, const int timeout_ms, const int extra_events)
{ {
#if IOEVENT_USE_URING #if IOEVENT_USE_URING
int result; int result;
@ -57,6 +57,7 @@ int ioevent_init(IOEventPoller *ioevent, const int size,
ioevent->iterator.count = 0; ioevent->iterator.count = 0;
#endif #endif
ioevent->service_name = service_name;
ioevent->size = size; ioevent->size = size;
ioevent->extra_events = extra_events; ioevent->extra_events = extra_events;

View File

@ -73,6 +73,7 @@ int kqueue_ev_convert(int16_t event, uint16_t flags);
#endif #endif
typedef struct ioevent_puller { typedef struct ioevent_puller {
const char *service_name;
int size; //max events (fd) int size; //max events (fd)
int extra_events; int extra_events;
#if IOEVENT_USE_URING #if IOEVENT_USE_URING
@ -156,8 +157,8 @@ typedef struct ioevent_puller {
extern "C" { extern "C" {
#endif #endif
int ioevent_init(IOEventPoller *ioevent, const int size, int ioevent_init(IOEventPoller *ioevent, const char *service_name,
const int timeout_ms, const int extra_events); const int size, const int timeout_ms, const int extra_events);
void ioevent_destroy(IOEventPoller *ioevent); void ioevent_destroy(IOEventPoller *ioevent);
int ioevent_attach(IOEventPoller *ioevent, const int fd, int ioevent_attach(IOEventPoller *ioevent, const int fd,

View File

@ -48,14 +48,21 @@ static int ioevent_process(IOEventPoller *ioevent)
if (ioevent->cqe->flags & IORING_CQE_F_NOTIF) { if (ioevent->cqe->flags & IORING_CQE_F_NOTIF) {
#ifdef IORING_NOTIF_USAGE_ZC_COPIED #ifdef IORING_NOTIF_USAGE_ZC_COPIED
if (!ioevent->send_zc_logged) { if (!ioevent->send_zc_logged) {
struct fast_task_info *task;
task = (struct fast_task_info *)pEntry;
ioevent->send_zc_logged = true; ioevent->send_zc_logged = true;
if (ioevent->cqe->res & IORING_NOTIF_USAGE_ZC_COPIED) { if (ioevent->cqe->res & IORING_NOTIF_USAGE_ZC_COPIED) {
logWarning("file: "__FILE__", line: %d, " logWarning("file: "__FILE__", line: %d, %s "
"io_uring send_zc: memory copy " "client %s:%u, io_uring send_zc: memory "
"instead of zero copy!", __LINE__); "copy instead of zero copy!", __LINE__,
ioevent->service_name, task->client_ip,
task->port);
} else { } else {
logInfo("file: "__FILE__", line: %d, " logInfo("file: "__FILE__", line: %d, %s "
"io_uring send_zc: zero copy OK.", __LINE__); "client %s:%u, io_uring send_zc: zero "
"copy OK.", __LINE__, ioevent->service_name,
task->client_ip, task->port);
} }
} }
#endif #endif

View File

@ -65,8 +65,8 @@ int fast_multi_sock_client_init_ex(FastMultiSockClient *client,
return EINVAL; return EINVAL;
} }
if ((result=ioevent_init(&client->ioevent, entry_count, if ((result=ioevent_init(&client->ioevent, "client",
timeout_ms, 0)) != 0) entry_count, timeout_ms, 0)) != 0)
{ {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"ioevent_init fail, errno: %d, error info: %s", "ioevent_init fail, errno: %d, error info: %s",