sf_nio_notify more graceful
parent
cce11f56cb
commit
4a92e31272
|
|
@ -144,9 +144,9 @@ static int open_next_binlog(SFBinlogWriterInfo *writer)
|
|||
char bak_filename[PATH_MAX];
|
||||
char date_str[32];
|
||||
|
||||
sprintf(bak_filename, "%s.%s", writer->file.name,
|
||||
formatDatetime(g_current_time, "%Y%m%d%H%M%S",
|
||||
date_str, sizeof(date_str)));
|
||||
snprintf(bak_filename, sizeof(bak_filename), "%s.%s",
|
||||
writer->file.name, formatDatetime(g_current_time,
|
||||
"%Y%m%d%H%M%S", date_str, sizeof(date_str)));
|
||||
if (rename(writer->file.name, bak_filename) == 0) {
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"binlog file %s exist, rename to %s",
|
||||
|
|
|
|||
11
src/sf_nio.c
11
src/sf_nio.c
|
|
@ -304,6 +304,7 @@ int sf_nio_notify(struct fast_task_info *task, const int stage)
|
|||
{
|
||||
int64_t n;
|
||||
int result;
|
||||
int old_stage;
|
||||
bool notify;
|
||||
|
||||
if (__sync_add_and_fetch(&task->canceled, 0)) {
|
||||
|
|
@ -321,19 +322,19 @@ int sf_nio_notify(struct fast_task_info *task, const int stage)
|
|||
}
|
||||
}
|
||||
|
||||
if (!__sync_bool_compare_and_swap(&task->nio_stages.notify,
|
||||
while (!__sync_bool_compare_and_swap(&task->nio_stages.notify,
|
||||
SF_NIO_STAGE_NONE, stage))
|
||||
{
|
||||
if (__sync_fetch_and_add(&task->nio_stages.notify, 0) == stage) {
|
||||
old_stage = __sync_fetch_and_add(&task->nio_stages.notify, 0);
|
||||
if (old_stage == stage) {
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"current stage: %d equals to the target, skip set",
|
||||
__LINE__, stage);
|
||||
return 0;
|
||||
} else {
|
||||
} else if (old_stage != SF_NIO_STAGE_NONE) {
|
||||
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);
|
||||
__LINE__, old_stage, SF_NIO_STAGE_NONE, stage);
|
||||
return EAGAIN;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ int sf_proto_set_body_length(struct fast_task_info *task)
|
|||
header = (SFCommonProtoHeader *)task->data;
|
||||
if (!SF_PROTO_CHECK_MAGIC(header->magic)) {
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s, magic "SF_PROTO_MAGIC_FORMAT
|
||||
"peer %s:%u, magic "SF_PROTO_MAGIC_FORMAT
|
||||
" is invalid, expect: "SF_PROTO_MAGIC_FORMAT,
|
||||
__LINE__, task->client_ip,
|
||||
__LINE__, task->client_ip, task->port,
|
||||
SF_PROTO_MAGIC_PARAMS(header->magic),
|
||||
SF_PROTO_MAGIC_EXPECT_PARAMS);
|
||||
return EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue