Skip to content

Commit

Permalink
fix an bug about FMTLOG_BLOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
Rao Meng committed Jan 19, 2022
1 parent 8ba235c commit bc3dfe4
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions fmtlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,14 +628,15 @@ class fmtlogT
size_t alloc_size = 8 + getArgSizes<0>(cstringSizes, args...);
if (threadBuffer == nullptr) preallocate();
do {
auto header = threadBuffer->varq.allocMsg(alloc_size);
if (!header) continue;
header->logId = logId;
char* out = (char*)(header + 1);
*(int64_t*)out = tsc;
out += 8;
encodeArgs<0>(cstringSizes, out, std::forward<Args>(args)...);
header->push(alloc_size);
if (auto header = threadBuffer->varq.allocMsg(alloc_size)) {
header->logId = logId;
char* out = (char*)(header + 1);
*(int64_t*)out = tsc;
out += 8;
encodeArgs<0>(cstringSizes, out, std::forward<Args>(args)...);
header->push(alloc_size);
break;
}
} while (FMTLOG_BLOCK);
}

Expand All @@ -648,16 +649,17 @@ class fmtlogT
size_t alloc_size = 8 + 8 + fmt_size;
if (threadBuffer == nullptr) preallocate();
do {
auto header = threadBuffer->varq.allocMsg(alloc_size);
if (!header) continue;
header->logId = (uint32_t)level;
char* out = (char*)(header + 1);
*(int64_t*)out = tscns.rdtsc();
out += 8;
*(const char**)out = location;
out += 8;
vformat_to(out, sv, fmt_args);
header->push(alloc_size);
if (auto header = threadBuffer->varq.allocMsg(alloc_size)) {
header->logId = (uint32_t)level;
char* out = (char*)(header + 1);
*(int64_t*)out = tscns.rdtsc();
out += 8;
*(const char**)out = location;
out += 8;
vformat_to(out, sv, fmt_args);
header->push(alloc_size);
break;
}
} while (FMTLOG_BLOCK);
}
};
Expand Down

0 comments on commit bc3dfe4

Please sign in to comment.