code simplification for last commit
parent
92fbcab0f4
commit
8bedbb6f27
27
src/sf_nio.c
27
src/sf_nio.c
|
|
@ -425,30 +425,6 @@ void sf_recv_notify_read(int sock, short event, void *arg)
|
|||
__LINE__, sock, errno, STRERROR(errno));
|
||||
}
|
||||
|
||||
if (SF_G_EPOLL_EDGE_TRIGGER) {
|
||||
while (1) {
|
||||
PTHREAD_MUTEX_LOCK(&thread_data->waiting_queue.lock);
|
||||
if (thread_data->waiting_queue.head != NULL) {
|
||||
task = thread_data->waiting_queue.head;
|
||||
thread_data->waiting_queue.head = task->notify_next;
|
||||
if (thread_data->waiting_queue.head == NULL) {
|
||||
thread_data->waiting_queue.tail = NULL;
|
||||
}
|
||||
} else {
|
||||
task = NULL;
|
||||
}
|
||||
PTHREAD_MUTEX_UNLOCK(&thread_data->waiting_queue.lock);
|
||||
|
||||
if (task != NULL) {
|
||||
stage = FC_ATOMIC_GET(task->nio_stages.notify);
|
||||
__sync_bool_compare_and_swap(&task->nio_stages.notify,
|
||||
stage, SF_NIO_STAGE_NONE);
|
||||
deal_notified_task(task, stage);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PTHREAD_MUTEX_LOCK(&thread_data->waiting_queue.lock);
|
||||
current = thread_data->waiting_queue.head;
|
||||
thread_data->waiting_queue.head = NULL;
|
||||
|
|
@ -460,7 +436,7 @@ void sf_recv_notify_read(int sock, short event, void *arg)
|
|||
current = current->notify_next;
|
||||
|
||||
stage = FC_ATOMIC_GET(task->nio_stages.notify);
|
||||
if (stage == SF_NIO_STAGE_CONTINUE) {
|
||||
if (stage == SF_NIO_STAGE_CONTINUE || SF_G_EPOLL_EDGE_TRIGGER) {
|
||||
/* MUST set to SF_NIO_STAGE_NONE first for re-entry */
|
||||
__sync_bool_compare_and_swap(&task->nio_stages.notify,
|
||||
stage, SF_NIO_STAGE_NONE);
|
||||
|
|
@ -471,7 +447,6 @@ void sf_recv_notify_read(int sock, short event, void *arg)
|
|||
stage, SF_NIO_STAGE_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int sf_send_add_event(struct fast_task_info *task)
|
||||
|
|
|
|||
Loading…
Reference in New Issue