mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
Replace various #ifdef RB_DEBUG with if constexpr for regression visibility.
This commit is contained in:
parent
44acfb5deb
commit
762703698c
10 changed files with 132 additions and 125 deletions
|
@ -92,9 +92,8 @@ __attribute__((always_inline, gnu_inline, artificial))
|
||||||
ircd::json::debug_valid_output(const string_view &in,
|
ircd::json::debug_valid_output(const string_view &in,
|
||||||
const size_t &expected)
|
const size_t &expected)
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
valid_output(in, expected);
|
valid_output(in, expected);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr ircd::json::name_hash_t
|
constexpr ircd::json::name_hash_t
|
||||||
|
|
|
@ -484,14 +484,17 @@ try
|
||||||
dock.notify_all();
|
dock.notify_all();
|
||||||
}};
|
}};
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
util::timer timer
|
||||||
util::timer timer;
|
|
||||||
log::debug
|
|
||||||
{
|
{
|
||||||
log, "%s enter",
|
RB_DEBUG_LEVEL
|
||||||
loghead(*client),
|
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
|
log::debug
|
||||||
|
{
|
||||||
|
log, "%s enter",
|
||||||
|
loghead(*client),
|
||||||
|
};
|
||||||
|
|
||||||
if(!client->main())
|
if(!client->main())
|
||||||
{
|
{
|
||||||
|
@ -499,15 +502,16 @@ try
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
char buf[64];
|
|
||||||
log::debug
|
|
||||||
{
|
{
|
||||||
log, "%s leave %s",
|
char buf[64];
|
||||||
loghead(*client),
|
log::debug
|
||||||
pretty(buf, timer.at<microseconds>(), true)
|
{
|
||||||
};
|
log, "%s leave %s",
|
||||||
#endif
|
loghead(*client),
|
||||||
|
pretty(buf, timer.at<microseconds>(), true)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
client->async();
|
client->async();
|
||||||
}
|
}
|
||||||
|
|
33
ircd/db.cc
33
ircd/db.cc
|
@ -4405,13 +4405,12 @@ ircd::db::throw_on_error::throw_on_error(const rocksdb::Status &status)
|
||||||
case Status::kNotFound:
|
case Status::kNotFound:
|
||||||
throw not_found{};
|
throw not_found{};
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
|
||||||
//case Status::kCorruption:
|
//case Status::kCorruption:
|
||||||
case Status::kNotSupported:
|
case Status::kNotSupported:
|
||||||
case Status::kInvalidArgument:
|
case Status::kInvalidArgument:
|
||||||
debugtrap();
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
|
debugtrap();
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
#endif
|
|
||||||
|
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
default:
|
default:
|
||||||
|
@ -4556,9 +4555,10 @@ ircd::db::commit(database &d,
|
||||||
rocksdb::WriteBatch &batch,
|
rocksdb::WriteBatch &batch,
|
||||||
const rocksdb::WriteOptions &opts)
|
const rocksdb::WriteOptions &opts)
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG
|
ircd::timer timer
|
||||||
ircd::timer timer;
|
{
|
||||||
#endif
|
RB_DEBUG_LEVEL
|
||||||
|
};
|
||||||
|
|
||||||
const std::lock_guard lock{d.write_mutex};
|
const std::lock_guard lock{d.write_mutex};
|
||||||
const ctx::uninterruptible ui;
|
const ctx::uninterruptible ui;
|
||||||
|
@ -4568,17 +4568,18 @@ ircd::db::commit(database &d,
|
||||||
d.d->Write(opts, &batch)
|
d.d->Write(opts, &batch)
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
char dbuf[192];
|
|
||||||
log::debug
|
|
||||||
{
|
{
|
||||||
log, "[%s] %lu COMMIT %s in %ld$us",
|
char dbuf[192];
|
||||||
d.name,
|
log::debug
|
||||||
sequence(d),
|
{
|
||||||
debug(dbuf, batch),
|
log, "[%s] %lu COMMIT %s in %ld$us",
|
||||||
timer.at<microseconds>().count()
|
d.name,
|
||||||
};
|
sequence(d),
|
||||||
#endif
|
debug(dbuf, batch),
|
||||||
|
timer.at<microseconds>().count()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
|
|
|
@ -1042,9 +1042,8 @@ try
|
||||||
opts->stats_dump_period_sec = 0; // Disable noise
|
opts->stats_dump_period_sec = 0; // Disable noise
|
||||||
opts->statistics = this->stats;
|
opts->statistics = this->stats;
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
opts->dump_malloc_stats = true;
|
opts->dump_malloc_stats = true;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Disables the timer to delete unused files; this operation occurs
|
// Disables the timer to delete unused files; this operation occurs
|
||||||
// instead with our compaction operations so we don't need to complicate.
|
// instead with our compaction operations so we don't need to complicate.
|
||||||
|
|
20
ircd/fs.cc
20
ircd/fs.cc
|
@ -273,17 +273,19 @@ ircd::fs::support::dump_info()
|
||||||
support
|
support
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
const unique_mutable_buffer buf
|
|
||||||
{
|
{
|
||||||
PATH_MAX_LEN + 1
|
const unique_mutable_buffer buf
|
||||||
};
|
{
|
||||||
|
PATH_MAX_LEN + 1
|
||||||
|
};
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "Current working directory: `%s'", cwd(buf)
|
log, "Current working directory: `%s'",
|
||||||
};
|
cwd(buf)
|
||||||
#endif
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -933,7 +933,6 @@ ircd::info::dump_sys_info()
|
||||||
fs::support::dump_info();
|
fs::support::dump_info();
|
||||||
|
|
||||||
// Additional detected system parameters
|
// Additional detected system parameters
|
||||||
//#ifdef RB_DEBUG
|
|
||||||
char buf[2][48];
|
char buf[2][48];
|
||||||
log::logf
|
log::logf
|
||||||
{
|
{
|
||||||
|
@ -948,7 +947,6 @@ ircd::info::dump_sys_info()
|
||||||
between(thp_enable, '[', ']'),
|
between(thp_enable, '[', ']'),
|
||||||
thp_size,
|
thp_size,
|
||||||
};
|
};
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UTSNAME_H
|
#ifdef HAVE_SYS_UTSNAME_H
|
||||||
|
|
|
@ -416,6 +416,7 @@ ircd_dl_signal_exception(int errcode,
|
||||||
//
|
//
|
||||||
#ifdef HAVE_DLFCN_H
|
#ifdef HAVE_DLFCN_H
|
||||||
#ifdef IRCD_MODS_HOOK_DLSYM
|
#ifdef IRCD_MODS_HOOK_DLSYM
|
||||||
|
#define RB_DEBUG_MODS_HOOK_DLSYM 0
|
||||||
|
|
||||||
extern "C" void *
|
extern "C" void *
|
||||||
__libc_dlsym(void *, const char *);
|
__libc_dlsym(void *, const char *);
|
||||||
|
@ -424,14 +425,13 @@ extern "C" void *
|
||||||
dlsym(void *const handle,
|
dlsym(void *const handle,
|
||||||
const char *const symbol)
|
const char *const symbol)
|
||||||
{
|
{
|
||||||
#ifdef RB_DEBUG_MODS_HOOK_DLSYM
|
if constexpr(RB_DEBUG_MODS_HOOK_DLSYM)
|
||||||
ircd::log::debug
|
ircd::log::debug
|
||||||
{
|
{
|
||||||
ircd::mods::log, "handle:%p symbol lookup '%s'",
|
ircd::mods::log, "handle:%p symbol lookup '%s'",
|
||||||
handle,
|
handle,
|
||||||
symbol
|
symbol
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
return __libc_dlsym(handle, symbol);
|
return __libc_dlsym(handle, symbol);
|
||||||
}
|
}
|
||||||
|
|
54
ircd/net.cc
54
ircd/net.cc
|
@ -2420,25 +2420,26 @@ noexcept try
|
||||||
if(timedout && ec == errc::operation_canceled)
|
if(timedout && ec == errc::operation_canceled)
|
||||||
ec = make_error_code(errc::timed_out);
|
ec = make_error_code(errc::timed_out);
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
const auto *const current_cipher
|
|
||||||
{
|
{
|
||||||
!ec?
|
const auto *const current_cipher
|
||||||
openssl::current_cipher(*this):
|
{
|
||||||
nullptr
|
!ec?
|
||||||
};
|
openssl::current_cipher(*this):
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
char ecbuf[64];
|
char ecbuf[64];
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "%s handshake cipher:%s %s",
|
log, "%s handshake cipher:%s %s",
|
||||||
loghead(*this),
|
loghead(*this),
|
||||||
current_cipher?
|
current_cipher?
|
||||||
openssl::name(*current_cipher):
|
openssl::name(*current_cipher):
|
||||||
"<NO CIPHER>"_sv,
|
"<NO CIPHER>"_sv,
|
||||||
string(ecbuf, ec)
|
string(ecbuf, ec)
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// Toggles the behavior of non-async functions; see func comment
|
// Toggles the behavior of non-async functions; see func comment
|
||||||
if(!ec)
|
if(!ec)
|
||||||
|
@ -2608,16 +2609,17 @@ noexcept try
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
thread_local char buf[16_KiB];
|
|
||||||
const critical_assertion ca;
|
|
||||||
log::debug
|
|
||||||
{
|
{
|
||||||
log, "verify[%s] %s",
|
thread_local char buf[16_KiB];
|
||||||
common_name(opts),
|
const critical_assertion ca;
|
||||||
openssl::print_subject(buf, cert)
|
log::debug
|
||||||
};
|
{
|
||||||
#endif
|
log, "verify[%s] %s",
|
||||||
|
common_name(opts),
|
||||||
|
openssl::print_subject(buf, cert)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -726,28 +726,29 @@ noexcept try
|
||||||
assert(it != end(handshaking));
|
assert(it != end(handshaking));
|
||||||
assert(openssl::get_app_data(*sock) == sock.get());
|
assert(openssl::get_app_data(*sock) == sock.get());
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
const auto *const current_cipher
|
|
||||||
{
|
{
|
||||||
!ec?
|
const auto *const current_cipher
|
||||||
openssl::current_cipher(*sock):
|
{
|
||||||
nullptr
|
!ec?
|
||||||
};
|
openssl::current_cipher(*sock):
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
char ecbuf[64];
|
char ecbuf[64];
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "%s %s handshook(%zd:%zu) cipher:%s %s",
|
log, "%s %s handshook(%zd:%zu) cipher:%s %s",
|
||||||
loghead(*sock),
|
loghead(*sock),
|
||||||
loghead(*this),
|
loghead(*this),
|
||||||
std::distance(cbegin(handshaking), it),
|
std::distance(cbegin(handshaking), it),
|
||||||
handshaking.size(),
|
handshaking.size(),
|
||||||
current_cipher?
|
current_cipher?
|
||||||
openssl::name(*current_cipher):
|
openssl::name(*current_cipher):
|
||||||
"<NO CIPHER>"_sv,
|
"<NO CIPHER>"_sv,
|
||||||
string(ecbuf, ec)
|
string(ecbuf, ec)
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
|
|
||||||
handshaking.erase(it);
|
handshaking.erase(it);
|
||||||
openssl::set_app_data(*sock, nullptr);
|
openssl::set_app_data(*sock, nullptr);
|
||||||
|
|
|
@ -1361,32 +1361,33 @@ ircd::resource::response::response(client &client,
|
||||||
eptr = std::current_exception();
|
eptr = std::current_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RB_DEBUG
|
if constexpr(RB_DEBUG_LEVEL)
|
||||||
const log::level level
|
|
||||||
{
|
{
|
||||||
http::severity(http::category(code))
|
const log::level level
|
||||||
};
|
{
|
||||||
|
http::severity(http::category(code))
|
||||||
|
};
|
||||||
|
|
||||||
log::logf
|
log::logf
|
||||||
{
|
{
|
||||||
log, level,
|
log, level,
|
||||||
"%s HTTP %u `%s' %s in %s; %s content-length:%s head-length:%zu %s%s",
|
"%s HTTP %u `%s' %s in %s; %s content-length:%s head-length:%zu %s%s",
|
||||||
loghead(client),
|
loghead(client),
|
||||||
uint(code),
|
uint(code),
|
||||||
client.request.head.path,
|
client.request.head.path,
|
||||||
http::status(code),
|
http::status(code),
|
||||||
rtime,
|
rtime,
|
||||||
content_type,
|
content_type,
|
||||||
ssize_t(content_length) >= 0?
|
ssize_t(content_length) >= 0?
|
||||||
lex_cast(content_length):
|
lex_cast(content_length):
|
||||||
"chunked"_sv,
|
"chunked"_sv,
|
||||||
wrote_head,
|
wrote_head,
|
||||||
eptr?
|
eptr?
|
||||||
"error:"_sv:
|
"error:"_sv:
|
||||||
string_view{},
|
string_view{},
|
||||||
what(eptr)
|
what(eptr)
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if(unlikely(eptr))
|
if(unlikely(eptr))
|
||||||
std::rethrow_exception(eptr);
|
std::rethrow_exception(eptr);
|
||||||
|
|
Loading…
Reference in a new issue