vendor : update cpp-httplib to 0.43.2 (#22548)
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
@@ -5,7 +5,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
HTTPLIB_VERSION = "refs/tags/v0.43.1"
|
HTTPLIB_VERSION = "refs/tags/v0.43.2"
|
||||||
|
|
||||||
vendor = {
|
vendor = {
|
||||||
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",
|
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",
|
||||||
|
|||||||
Vendored
+33
-35
@@ -1464,8 +1464,9 @@ bool mmap::open(const char *path) {
|
|||||||
auto wpath = u8string_to_wstring(path);
|
auto wpath = u8string_to_wstring(path);
|
||||||
if (wpath.empty()) { return false; }
|
if (wpath.empty()) { return false; }
|
||||||
|
|
||||||
hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
hFile_ =
|
||||||
OPEN_EXISTING, NULL);
|
::CreateFile2(wpath.c_str(), GENERIC_READ,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, NULL);
|
||||||
|
|
||||||
if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
|
if (hFile_ == INVALID_HANDLE_VALUE) { return false; }
|
||||||
|
|
||||||
@@ -2052,56 +2053,50 @@ int getaddrinfo_with_timeout(const char *node, const char *service,
|
|||||||
return 0;
|
return 0;
|
||||||
#elif defined(_GNU_SOURCE) && defined(__GLIBC__) && \
|
#elif defined(_GNU_SOURCE) && defined(__GLIBC__) && \
|
||||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
|
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
|
||||||
// Linux implementation using getaddrinfo_a for asynchronous DNS resolution
|
// #2431: gai_cancel() is non-blocking and may return EAI_NOTCANCELED while
|
||||||
struct gaicb request;
|
// the resolver worker still references the stack-local gaicb. The cancel
|
||||||
|
// path therefore waits (gai_suspend with no timeout) for the worker to
|
||||||
|
// actually finish before letting the stack frame go. The trade-off is that
|
||||||
|
// a wedged DNS server can hold this thread for the system resolver timeout
|
||||||
|
// (~30s by default) past the caller's connection timeout.
|
||||||
|
struct gaicb request {};
|
||||||
struct gaicb *requests[1] = {&request};
|
struct gaicb *requests[1] = {&request};
|
||||||
struct sigevent sevp;
|
struct sigevent sevp {};
|
||||||
struct timespec timeout;
|
struct timespec timeout {
|
||||||
|
timeout_sec, 0
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize the request structure
|
|
||||||
memset(&request, 0, sizeof(request));
|
|
||||||
request.ar_name = node;
|
request.ar_name = node;
|
||||||
request.ar_service = service;
|
request.ar_service = service;
|
||||||
request.ar_request = hints;
|
request.ar_request = hints;
|
||||||
|
|
||||||
// Set up timeout
|
|
||||||
timeout.tv_sec = timeout_sec;
|
|
||||||
timeout.tv_nsec = 0;
|
|
||||||
|
|
||||||
// Initialize sigevent structure (not used, but required)
|
|
||||||
memset(&sevp, 0, sizeof(sevp));
|
|
||||||
sevp.sigev_notify = SIGEV_NONE;
|
sevp.sigev_notify = SIGEV_NONE;
|
||||||
|
|
||||||
// Start asynchronous resolution
|
int rc = getaddrinfo_a(GAI_NOWAIT, requests, 1, &sevp);
|
||||||
int start_result = getaddrinfo_a(GAI_NOWAIT, requests, 1, &sevp);
|
if (rc != 0) { return rc; }
|
||||||
if (start_result != 0) { return start_result; }
|
|
||||||
|
|
||||||
// Wait for completion with timeout
|
auto cleanup = scope_exit([&] {
|
||||||
int wait_result =
|
if (request.ar_result) { freeaddrinfo(request.ar_result); }
|
||||||
gai_suspend((const struct gaicb *const *)requests, 1, &timeout);
|
});
|
||||||
|
|
||||||
|
int wait_result = gai_suspend(requests, 1, &timeout);
|
||||||
|
|
||||||
if (wait_result == 0 || wait_result == EAI_ALLDONE) {
|
if (wait_result == 0 || wait_result == EAI_ALLDONE) {
|
||||||
// Completed successfully, get the result
|
|
||||||
int gai_result = gai_error(&request);
|
int gai_result = gai_error(&request);
|
||||||
if (gai_result == 0) {
|
if (gai_result == 0) {
|
||||||
*res = request.ar_result;
|
*res = request.ar_result;
|
||||||
|
request.ar_result = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
// Clean up on error
|
|
||||||
if (request.ar_result) { freeaddrinfo(request.ar_result); }
|
|
||||||
return gai_result;
|
|
||||||
}
|
}
|
||||||
} else if (wait_result == EAI_AGAIN) {
|
return gai_result;
|
||||||
// Timeout occurred, cancel the request
|
|
||||||
gai_cancel(&request);
|
|
||||||
return EAI_AGAIN;
|
|
||||||
} else {
|
|
||||||
// Other error occurred
|
|
||||||
gai_cancel(&request);
|
|
||||||
return wait_result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gai_cancel(&request);
|
||||||
|
while (gai_error(&request) == EAI_INPROGRESS) {
|
||||||
|
gai_suspend(requests, 1, nullptr);
|
||||||
|
}
|
||||||
|
return wait_result;
|
||||||
#else
|
#else
|
||||||
// Fallback implementation using thread-based timeout for other Unix systems
|
// Fallback implementation using thread-based timeout for other Unix systems.
|
||||||
|
|
||||||
struct GetAddrInfoState {
|
struct GetAddrInfoState {
|
||||||
~GetAddrInfoState() {
|
~GetAddrInfoState() {
|
||||||
@@ -14142,6 +14137,9 @@ ssize_t read(session_t session, void *buf, size_t len, TlsError &err) {
|
|||||||
err.code = impl::map_mbedtls_error(ret, err.sys_errno);
|
err.code = impl::map_mbedtls_error(ret, err.sys_errno);
|
||||||
err.backend_code = static_cast<uint64_t>(-ret);
|
err.backend_code = static_cast<uint64_t>(-ret);
|
||||||
impl::mbedtls_last_error() = ret;
|
impl::mbedtls_last_error() = ret;
|
||||||
|
// mbedTLS signals a clean close_notify via a negative error code rather
|
||||||
|
// than 0; surface it as a clean EOF the way OpenSSL/wolfSSL do.
|
||||||
|
if (err.code == ErrorCode::PeerClosed) { return 0; }
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
-2
@@ -8,8 +8,8 @@
|
|||||||
#ifndef CPPHTTPLIB_HTTPLIB_H
|
#ifndef CPPHTTPLIB_HTTPLIB_H
|
||||||
#define CPPHTTPLIB_HTTPLIB_H
|
#define CPPHTTPLIB_HTTPLIB_H
|
||||||
|
|
||||||
#define CPPHTTPLIB_VERSION "0.43.1"
|
#define CPPHTTPLIB_VERSION "0.43.2"
|
||||||
#define CPPHTTPLIB_VERSION_NUM "0x002b01"
|
#define CPPHTTPLIB_VERSION_NUM "0x002b02"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00
|
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0A00
|
||||||
|
|||||||
Reference in New Issue
Block a user