From 42c8a65a8ffc5b4412f319d6f63fc219f5b36ec8 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Wed, 28 Oct 2020 16:20:41 +0800 Subject: [PATCH] logDebug when then nio stage equals to the target --- src/sf_nio.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/sf_nio.c b/src/sf_nio.c index 85f3599..b5fc9b6 100644 --- a/src/sf_nio.c +++ b/src/sf_nio.c @@ -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);