Skip to content

Commit 41be1e2

Browse files
committed
Code cleanup
1 parent 6e52d0a commit 41be1e2

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

httplib.h

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,32 +3800,19 @@ inline int getaddrinfo_with_timeout(const char *node, const char *service,
38003800
// Fallback implementation using thread-based timeout for other Unix systems
38013801

38023802
struct GetAddrInfoState {
3803-
std::mutex mutex{};
3804-
std::condition_variable result_cv{};
3805-
bool completed{false};
3806-
int result{0};
3807-
std::string node{};
3808-
std::string service{};
3809-
struct addrinfo hints {};
3810-
struct addrinfo *info{nullptr};
3803+
std::mutex mutex;
3804+
std::condition_variable result_cv;
3805+
bool completed = false;
3806+
int result = EAI_SYSTEM;
3807+
std::string node = node;
3808+
std::string service = service;
3809+
struct addrinfo hints = hints;
3810+
struct addrinfo *info = nullptr;
38113811
};
38123812

38133813
// Allocate on the heap, so the resolver thread can keep using the data.
38143814
auto state = std::make_shared<GetAddrInfoState>();
38153815

3816-
state->result = EAI_SYSTEM;
3817-
state->node = node;
3818-
state->service = service;
3819-
state->hints.ai_flags = hints->ai_flags;
3820-
state->hints.ai_family = hints->ai_family;
3821-
state->hints.ai_socktype = hints->ai_socktype;
3822-
state->hints.ai_protocol = hints->ai_protocol;
3823-
// The remaining fields of "hints" must be zeroed, so do not copy them.
3824-
assert(hints->ai_addrlen == 0);
3825-
assert(hints->ai_addr == nullptr);
3826-
assert(hints->ai_canonname == nullptr);
3827-
assert(hints->ai_next == nullptr);
3828-
38293816
std::thread resolve_thread([=]() {
38303817
auto thread_result = getaddrinfo(
38313818
state->node.c_str(), state->service.c_str(), hints, &state->info);

0 commit comments

Comments
 (0)