correct compile error in Linux
parent
965c8277c7
commit
c0df88aabf
16
src/sf_nio.c
16
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->nio_stage = stage;
|
||||||
task->next = NULL;
|
task->next = NULL;
|
||||||
|
|
||||||
pthread_mutex_lock(&task->thread_data.waiting_queue.lock);
|
pthread_mutex_lock(&task->thread_data->waiting_queue.lock);
|
||||||
if (task->thread_data.waiting_queue.tail == NULL) {
|
if (task->thread_data->waiting_queue.tail == NULL) {
|
||||||
task->thread_data.waiting_queue.head = task;
|
task->thread_data->waiting_queue.head = task;
|
||||||
notify = true;
|
notify = true;
|
||||||
} else {
|
} else {
|
||||||
task->thread_data.waiting_queue.tail->next = task;
|
task->thread_data->waiting_queue.tail->next = task;
|
||||||
notify = false;
|
notify = false;
|
||||||
}
|
}
|
||||||
task->thread_data.waiting_queue.tail = task;
|
task->thread_data->waiting_queue.tail = task;
|
||||||
pthread_mutex_unlock(&task->thread_data.waiting_queue.lock);
|
pthread_mutex_unlock(&task->thread_data->waiting_queue.lock);
|
||||||
|
|
||||||
if (notify) {
|
if (notify) {
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
@ -253,10 +253,10 @@ void sf_recv_notify_read(int sock, short event, void *arg)
|
||||||
__LINE__, sock, errno, STRERROR(errno));
|
__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;
|
current = thread_data->waiting_queue.head;
|
||||||
thread_data->waiting_queue.head = thread_data->waiting_queue.tail = NULL;
|
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) {
|
while (current != NULL) {
|
||||||
task = current;
|
task = current;
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if defined(OS_LINUX)
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
#endif
|
|
||||||
#include "fastcommon/logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fastcommon/sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fastcommon/shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
|
|
@ -23,6 +20,9 @@
|
||||||
#include "sf_nio.h"
|
#include "sf_nio.h"
|
||||||
#include "sf_service.h"
|
#include "sf_service.h"
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#include <sys/eventfd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool bTerminateFlag = false;
|
static bool bTerminateFlag = false;
|
||||||
|
|
||||||
|
|
@ -177,7 +177,8 @@ int sf_service_init_ex(SFContext *sf_context,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
#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;
|
result = errno != 0 ? errno : EPERM;
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"call eventfd fail, "
|
"call eventfd fail, "
|
||||||
|
|
@ -185,9 +186,9 @@ int sf_service_init_ex(SFContext *sf_context,
|
||||||
__LINE__, result, strerror(result));
|
__LINE__, result, strerror(result));
|
||||||
break;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue