lib/curl: fix coding style

This commit is contained in:
Max Kellermann 2019-08-19 21:16:29 +02:00
parent 8cd5e79fbd
commit dab39dc778
3 changed files with 22 additions and 21 deletions

View File

@ -48,7 +48,7 @@ public:
CurlSocket(CurlGlobal &_global, EventLoop &_loop, SocketDescriptor _fd)
:SocketMonitor(_fd, _loop), global(_global) {}
~CurlSocket() {
~CurlSocket() noexcept {
/* TODO: sometimes, CURL uses CURL_POLL_REMOVE after
closing the socket, and sometimes, it uses
CURL_POLL_REMOVE just to move the (still open)
@ -109,7 +109,8 @@ CurlGlobal::CurlGlobal(EventLoop &_loop)
int
CurlSocket::SocketFunction(gcc_unused CURL *easy,
curl_socket_t s, int action,
void *userp, void *socketp) noexcept {
void *userp, void *socketp) noexcept
{
auto &global = *(CurlGlobal *)userp;
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
CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
{
@ -236,11 +251,11 @@ CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
}
int
CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms,
CurlGlobal::TimerFunction(gcc_unused CURLM *_multi, long timeout_ms,
void *userp) noexcept
{
auto &global = *(CurlGlobal *)userp;
assert(_global == global.multi.Get());
assert(_multi == global.multi.Get());
global.UpdateTimeout(timeout_ms);
return 0;
@ -251,17 +266,3 @@ CurlGlobal::OnTimeout() noexcept
{
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();
}

View File

@ -70,13 +70,13 @@ public:
void SocketAction(curl_socket_t fd, int ev_bitmask) noexcept;
void InvalidateSockets() {
void InvalidateSockets() noexcept {
SocketAction(CURL_SOCKET_TIMEOUT, 0);
}
private:
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;
/* callback for #timeout_event */

View File

@ -42,7 +42,7 @@ class CurlSlist {
struct curl_slist *head = nullptr;
public:
CurlSlist() = default;
CurlSlist() noexcept = default;
CurlSlist(CurlSlist &&src) noexcept
:head(std::exchange(src.head, nullptr)) {}