mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-01 07:30:02 +00:00
resolver: replace init's cleanup lambda with a member; lcov --list ignores inconsistent
gcov 15 marks the lambda as not hit while its lines are, which lcov 2 rejects. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -139,6 +139,7 @@ if (ENABLE_COVERAGE)
|
||||
--include ${PROJECT_SOURCE_DIR}/src/*
|
||||
--ignore-errors mismatch,unused,empty,gcov,inconsistent
|
||||
COMMAND ${LCOV_EXECUTABLE} --list ${PROJECT_BINARY_DIR}/coverage.info
|
||||
--ignore-errors inconsistent
|
||||
COMMAND ${GENHTML_EXECUTABLE} ${PROJECT_BINARY_DIR}/coverage.info
|
||||
--ignore-errors inconsistent
|
||||
--output-directory ${PROJECT_BINARY_DIR}/coverage-html
|
||||
|
||||
+10
-7
@@ -40,14 +40,9 @@ Status Resolver::init(event::Loop &loop, const char *nameservers, bool ipv6_firs
|
||||
ares_library_cleanup();
|
||||
return fail(Errc::config);
|
||||
}
|
||||
auto abandon = [this] {
|
||||
ares_destroy(channel_);
|
||||
channel_ = nullptr;
|
||||
ares_library_cleanup();
|
||||
};
|
||||
if (nameservers != nullptr && ares_set_servers_ports_csv(channel_, nameservers) != ARES_SUCCESS) {
|
||||
LOGE("failed to set nameservers %s", nameservers);
|
||||
abandon();
|
||||
abandon_channel();
|
||||
return fail(Errc::config);
|
||||
}
|
||||
loop_ = &loop;
|
||||
@@ -56,12 +51,20 @@ Status Resolver::init(event::Loop &loop, const char *nameservers, bool ipv6_firs
|
||||
w.owner = this;
|
||||
}
|
||||
if (Status opened = timer_.open(loop, *this); !opened) {
|
||||
abandon();
|
||||
abandon_channel();
|
||||
return opened;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// Undo init() after the channel was created.
|
||||
void Resolver::abandon_channel() noexcept
|
||||
{
|
||||
ares_destroy(channel_);
|
||||
channel_ = nullptr;
|
||||
ares_library_cleanup();
|
||||
}
|
||||
|
||||
Status Resolver::resolve(const char *host, std::uint16_t port, const ResolveCallback &cb) noexcept
|
||||
{
|
||||
if (channel_ == nullptr) {
|
||||
|
||||
@@ -82,6 +82,7 @@ private:
|
||||
static void sock_state(void *data, ares_socket_t s, int readable, int writable) noexcept;
|
||||
static void on_host(void *arg, int status, int timeouts, hostent *he) noexcept;
|
||||
void on_timer() noexcept;
|
||||
void abandon_channel() noexcept;
|
||||
void rearm() noexcept;
|
||||
void finish(Query *q, int status) noexcept;
|
||||
void on_closed_all() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user