add macro sf_nio_notify_silence

connection_manager
YuQing 2020-09-22 17:26:46 +08:00
parent 0c4b35719c
commit 62a35f03d5
3 changed files with 23 additions and 14 deletions

View File

@ -318,7 +318,7 @@ int idempotency_client_channel_push(struct idempotency_client_channel *channel,
if (notify) { if (notify) {
if (__sync_add_and_fetch(&channel->in_ioevent, 0)) { if (__sync_add_and_fetch(&channel->in_ioevent, 0)) {
if (__sync_add_and_fetch(&channel->established, 0)) { if (__sync_add_and_fetch(&channel->established, 0)) {
sf_nio_notify(channel->task, SF_NIO_STAGE_CONTINUE); sf_nio_notify_silence(channel->task, SF_NIO_STAGE_CONTINUE);
} }
} else { } else {
return idempotency_client_channel_check_reconnect(channel); return idempotency_client_channel_check_reconnect(channel);

View File

@ -285,7 +285,7 @@ static int sf_nio_deal_task(struct fast_task_info *task)
} }
int sf_nio_notify_ex(struct fast_task_info *task, const int new_stage, int sf_nio_notify_ex(struct fast_task_info *task, const int new_stage,
const char *file, const int line) const int log_level, const char *file, const int line)
{ {
int64_t n; int64_t n;
int result; int result;
@ -298,11 +298,14 @@ int sf_nio_notify_ex(struct fast_task_info *task, const int new_stage,
new_stage == SF_NIO_STAGE_CLOSE)) new_stage == SF_NIO_STAGE_CLOSE))
{ {
if (SF_NIO_STAGE_IS_INPROGRESS(old_stage)) { if (SF_NIO_STAGE_IS_INPROGRESS(old_stage)) {
logWarning("file: "__FILE__", line: %d, " if (FC_LOG_BY_LEVEL(log_level)) {
"from caller {file: %s, line: %d}, " log_it_ex(&g_log_context, log_level,
"client ip: %s, nio stage in progress, " "file: "__FILE__", line: %d, "
"current stage: %d, skip set to %d", __LINE__, "from caller {file: %s, line: %d}, "
file, line, task->client_ip, old_stage, new_stage); "client ip: %s, nio stage in progress, "
"current stage: %d, skip set to %d", __LINE__,
file, line, task->client_ip, old_stage, new_stage);
}
return EBUSY; return EBUSY;
} }
} }
@ -310,11 +313,14 @@ int sf_nio_notify_ex(struct fast_task_info *task, const int new_stage,
if (!__sync_bool_compare_and_swap(&task->nio_stage, if (!__sync_bool_compare_and_swap(&task->nio_stage,
old_stage, new_stage)) old_stage, new_stage))
{ {
logWarning("file: "__FILE__", line: %d, " if (FC_LOG_BY_LEVEL(log_level)) {
"from caller {file: %s, line: %d}, " log_it_ex(&g_log_context, log_level,
"client ip: %s, skip set stage to %d because stage " "file: "__FILE__", line: %d, "
"changed, current stage: %d", __LINE__, file, line, "from caller {file: %s, line: %d}, "
task->client_ip, new_stage, SF_NIO_TASK_STAGE_FETCH(task)); "client ip: %s, skip set stage to %d because stage "
"changed, current stage: %d", __LINE__, file, line,
task->client_ip, new_stage, SF_NIO_TASK_STAGE_FETCH(task));
}
return EEXIST; return EEXIST;
} }

View File

@ -51,10 +51,13 @@ int sf_client_sock_read(int sock, short event, void *arg);
void sf_task_finish_clean_up(struct fast_task_info *task); void sf_task_finish_clean_up(struct fast_task_info *task);
int sf_nio_notify_ex(struct fast_task_info *task, const int new_stage, int sf_nio_notify_ex(struct fast_task_info *task, const int new_stage,
const char *file, const int line); const int log_level, const char *file, const int line);
#define sf_nio_notify(task, new_stage) \ #define sf_nio_notify(task, new_stage) \
sf_nio_notify_ex(task, new_stage, __FILE__, __LINE__) sf_nio_notify_ex(task, new_stage, LOG_WARNING, __FILE__, __LINE__)
#define sf_nio_notify_silence(task, new_stage) \
sf_nio_notify_ex(task, new_stage, LOG_NOTHING, __FILE__, __LINE__)
#define sf_nio_task_is_idle(task) \ #define sf_nio_task_is_idle(task) \
(task->offset == 0 && task->length == 0) (task->offset == 0 && task->length == 0)