lib/curl: fix coding style
This commit is contained in:
parent
8cd5e79fbd
commit
dab39dc778
@ -48,7 +48,7 @@ public:
|
|||||||
CurlSocket(CurlGlobal &_global, EventLoop &_loop, SocketDescriptor _fd)
|
CurlSocket(CurlGlobal &_global, EventLoop &_loop, SocketDescriptor _fd)
|
||||||
:SocketMonitor(_fd, _loop), global(_global) {}
|
:SocketMonitor(_fd, _loop), global(_global) {}
|
||||||
|
|
||||||
~CurlSocket() {
|
~CurlSocket() noexcept {
|
||||||
/* TODO: sometimes, CURL uses CURL_POLL_REMOVE after
|
/* TODO: sometimes, CURL uses CURL_POLL_REMOVE after
|
||||||
closing the socket, and sometimes, it uses
|
closing the socket, and sometimes, it uses
|
||||||
CURL_POLL_REMOVE just to move the (still open)
|
CURL_POLL_REMOVE just to move the (still open)
|
||||||
@ -109,7 +109,8 @@ CurlGlobal::CurlGlobal(EventLoop &_loop)
|
|||||||
int
|
int
|
||||||
CurlSocket::SocketFunction(gcc_unused CURL *easy,
|
CurlSocket::SocketFunction(gcc_unused CURL *easy,
|
||||||
curl_socket_t s, int action,
|
curl_socket_t s, int action,
|
||||||
void *userp, void *socketp) noexcept {
|
void *userp, void *socketp) noexcept
|
||||||
|
{
|
||||||
auto &global = *(CurlGlobal *)userp;
|
auto &global = *(CurlGlobal *)userp;
|
||||||
CurlSocket *cs = (CurlSocket *)socketp;
|
CurlSocket *cs = (CurlSocket *)socketp;
|
||||||
|
|
||||||
@ -217,6 +218,20 @@ CurlGlobal::ReadInfo() noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask) noexcept
|
||||||
|
{
|
||||||
|
int running_handles;
|
||||||
|
CURLMcode mcode = curl_multi_socket_action(multi.Get(), fd, ev_bitmask,
|
||||||
|
&running_handles);
|
||||||
|
if (mcode != CURLM_OK)
|
||||||
|
FormatError(curlm_domain,
|
||||||
|
"curl_multi_socket_action() failed: %s",
|
||||||
|
curl_multi_strerror(mcode));
|
||||||
|
|
||||||
|
defer_read_info.Schedule();
|
||||||
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
|
CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
|
||||||
{
|
{
|
||||||
@ -236,11 +251,11 @@ CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms,
|
CurlGlobal::TimerFunction(gcc_unused CURLM *_multi, long timeout_ms,
|
||||||
void *userp) noexcept
|
void *userp) noexcept
|
||||||
{
|
{
|
||||||
auto &global = *(CurlGlobal *)userp;
|
auto &global = *(CurlGlobal *)userp;
|
||||||
assert(_global == global.multi.Get());
|
assert(_multi == global.multi.Get());
|
||||||
|
|
||||||
global.UpdateTimeout(timeout_ms);
|
global.UpdateTimeout(timeout_ms);
|
||||||
return 0;
|
return 0;
|
||||||
@ -251,17 +266,3 @@ CurlGlobal::OnTimeout() noexcept
|
|||||||
{
|
{
|
||||||
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask) noexcept
|
|
||||||
{
|
|
||||||
int running_handles;
|
|
||||||
CURLMcode mcode = curl_multi_socket_action(multi.Get(), fd, ev_bitmask,
|
|
||||||
&running_handles);
|
|
||||||
if (mcode != CURLM_OK)
|
|
||||||
FormatError(curlm_domain,
|
|
||||||
"curl_multi_socket_action() failed: %s",
|
|
||||||
curl_multi_strerror(mcode));
|
|
||||||
|
|
||||||
defer_read_info.Schedule();
|
|
||||||
}
|
|
||||||
|
@ -70,13 +70,13 @@ public:
|
|||||||
|
|
||||||
void SocketAction(curl_socket_t fd, int ev_bitmask) noexcept;
|
void SocketAction(curl_socket_t fd, int ev_bitmask) noexcept;
|
||||||
|
|
||||||
void InvalidateSockets() {
|
void InvalidateSockets() noexcept {
|
||||||
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateTimeout(long timeout_ms) noexcept;
|
void UpdateTimeout(long timeout_ms) noexcept;
|
||||||
static int TimerFunction(CURLM *global, long timeout_ms,
|
static int TimerFunction(CURLM *multi, long timeout_ms,
|
||||||
void *userp) noexcept;
|
void *userp) noexcept;
|
||||||
|
|
||||||
/* callback for #timeout_event */
|
/* callback for #timeout_event */
|
||||||
|
@ -42,7 +42,7 @@ class CurlSlist {
|
|||||||
struct curl_slist *head = nullptr;
|
struct curl_slist *head = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurlSlist() = default;
|
CurlSlist() noexcept = default;
|
||||||
|
|
||||||
CurlSlist(CurlSlist &&src) noexcept
|
CurlSlist(CurlSlist &&src) noexcept
|
||||||
:head(std::exchange(src.head, nullptr)) {}
|
:head(std::exchange(src.head, nullptr)) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user