logDebug when then nio stage equals to the target

connection_manager
YuQing 2020-10-28 16:20:41 +08:00
parent b9b5dd490d
commit 42c8a65a8f
1 changed files with 12 additions and 5 deletions

View File

@ -324,11 +324,18 @@ int sf_nio_notify(struct fast_task_info *task, const int stage)
if (!__sync_bool_compare_and_swap(&task->nio_stages.notify,
SF_NIO_STAGE_NONE, stage))
{
logWarning("file: "__FILE__", line: %d, "
"current stage: %d != %d, skip set stage to %d",
__LINE__, __sync_fetch_and_sub(&task->nio_stages.notify, 0),
SF_NIO_STAGE_NONE, stage);
return EAGAIN;
if (__sync_fetch_and_add(&task->nio_stages.notify, 0) == stage) {
logDebug("file: "__FILE__", line: %d, "
"current stage: %d equals to the target, skip set",
__LINE__, stage);
return 0;
} else {
logWarning("file: "__FILE__", line: %d, "
"current stage: %d != %d, skip set stage to %d",
__LINE__, __sync_fetch_and_add(&task->nio_stages.notify, 0),
SF_NIO_STAGE_NONE, stage);
return EAGAIN;
}
}
PTHREAD_MUTEX_LOCK(&task->thread_data->waiting_queue.lock);