From c0df88aabff263af600d3cacc76ca322d3c8ea29 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sun, 8 Mar 2020 16:54:43 +0800 Subject: [PATCH] correct compile error in Linux --- src/sf_nio.c | 16 ++++++++-------- src/sf_service.c | 13 +++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/sf_nio.c b/src/sf_nio.c index 97accdd..4f07210 100644 --- a/src/sf_nio.c +++ b/src/sf_nio.c @@ -211,16 +211,16 @@ int sf_nio_notify(struct fast_task_info *task, const int stage) task->nio_stage = stage; task->next = NULL; - pthread_mutex_lock(&task->thread_data.waiting_queue.lock); - if (task->thread_data.waiting_queue.tail == NULL) { - task->thread_data.waiting_queue.head = task; + pthread_mutex_lock(&task->thread_data->waiting_queue.lock); + if (task->thread_data->waiting_queue.tail == NULL) { + task->thread_data->waiting_queue.head = task; notify = true; } else { - task->thread_data.waiting_queue.tail->next = task; + task->thread_data->waiting_queue.tail->next = task; notify = false; } - task->thread_data.waiting_queue.tail = task; - pthread_mutex_unlock(&task->thread_data.waiting_queue.lock); + task->thread_data->waiting_queue.tail = task; + pthread_mutex_unlock(&task->thread_data->waiting_queue.lock); if (notify) { n = 1; @@ -253,10 +253,10 @@ void sf_recv_notify_read(int sock, short event, void *arg) __LINE__, sock, errno, STRERROR(errno)); } - pthread_mutex_lock(&thread_data.waiting_queue.lock); + pthread_mutex_lock(&thread_data->waiting_queue.lock); current = thread_data->waiting_queue.head; thread_data->waiting_queue.head = thread_data->waiting_queue.tail = NULL; - pthread_mutex_unlock(&thread_data.waiting_queue.lock); + pthread_mutex_unlock(&thread_data->waiting_queue.lock); while (current != NULL) { task = current; diff --git a/src/sf_service.c b/src/sf_service.c index 19a21c6..4569cdd 100644 --- a/src/sf_service.c +++ b/src/sf_service.c @@ -10,9 +10,6 @@ #include #include #include -#if defined(OS_LINUX) -#include -#endif #include "fastcommon/logger.h" #include "fastcommon/sockopt.h" #include "fastcommon/shared_func.h" @@ -23,6 +20,9 @@ #include "sf_nio.h" #include "sf_service.h" +#if defined(OS_LINUX) +#include +#endif static bool bTerminateFlag = false; @@ -177,7 +177,8 @@ int sf_service_init_ex(SFContext *sf_context, } #if defined(OS_LINUX) - if ((NOTIFY_READ_FD(thread_data)=eventfd(0, EFD_NONBLOCK) < 0) { + NOTIFY_READ_FD(thread_data) = eventfd(0, EFD_NONBLOCK); + if (NOTIFY_READ_FD(thread_data) < 0) { result = errno != 0 ? errno : EPERM; logError("file: "__FILE__", line: %d, " "call eventfd fail, " @@ -185,9 +186,9 @@ int sf_service_init_ex(SFContext *sf_context, __LINE__, result, strerror(result)); break; } - NOTIFY_WRITE_FD(tdata) = NOTIFY_READ_FD(thread_data); + NOTIFY_WRITE_FD(thread_data) = NOTIFY_READ_FD(thread_data); - if ((result=init_pthread_lock(&thread_data.waiting_queue.lock)) != 0) { + if ((result=init_pthread_lock(&thread_data->waiting_queue.lock)) != 0) { return result; } #else