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) {
fast_timer_add_ex(timer, entry, new_expires, true);
}
return result;
}
return 0;

View File

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

View File

@ -73,6 +73,7 @@ int kqueue_ev_convert(int16_t event, uint16_t flags);
#endif
typedef struct ioevent_puller {
const char *service_name;
int size; //max events (fd)
int extra_events;
#if IOEVENT_USE_URING
@ -156,8 +157,8 @@ typedef struct ioevent_puller {
extern "C" {
#endif
int ioevent_init(IOEventPoller *ioevent, const int size,
const int timeout_ms, const int extra_events);
int ioevent_init(IOEventPoller *ioevent, const char *service_name,
const int size, const int timeout_ms, const int extra_events);
void ioevent_destroy(IOEventPoller *ioevent);
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) {
#ifdef IORING_NOTIF_USAGE_ZC_COPIED
if (!ioevent->send_zc_logged) {
struct fast_task_info *task;
task = (struct fast_task_info *)pEntry;
ioevent->send_zc_logged = true;
if (ioevent->cqe->res & IORING_NOTIF_USAGE_ZC_COPIED) {
logWarning("file: "__FILE__", line: %d, "
"io_uring send_zc: memory copy "
"instead of zero copy!", __LINE__);
logWarning("file: "__FILE__", line: %d, %s "
"client %s:%u, io_uring send_zc: memory "
"copy instead of zero copy!", __LINE__,
ioevent->service_name, task->client_ip,
task->port);
} else {
logInfo("file: "__FILE__", line: %d, "
"io_uring send_zc: zero copy OK.", __LINE__);
logInfo("file: "__FILE__", line: %d, %s "
"client %s:%u, io_uring send_zc: zero "
"copy OK.", __LINE__, ioevent->service_name,
task->client_ip, task->port);
}
}
#endif

View File

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