diff options
author | Max Kellermann <max@duempel.org> | 2013-11-06 18:21:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-06 19:05:45 +0100 |
commit | 8b838ff9ea2a08c99275531ed5f6b5ddfe4406fe (patch) | |
tree | 6b06ffee9bc229df7227ec1a517187f8bb06834d /src | |
parent | 154bdf0bca49f36f6ff8bc7f001634735ceb0b73 (diff) | |
download | mpd-8b838ff9ea2a08c99275531ed5f6b5ddfe4406fe.tar.gz mpd-8b838ff9ea2a08c99275531ed5f6b5ddfe4406fe.tar.xz mpd-8b838ff9ea2a08c99275531ed5f6b5ddfe4406fe.zip |
input/curl: use CURLOPT_PRIVATE
Replaces the loop in input_curl_find_request().
Diffstat (limited to 'src')
-rw-r--r-- | src/input/CurlInputPlugin.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx index aca9d9608..728a0c177 100644 --- a/src/input/CurlInputPlugin.cxx +++ b/src/input/CurlInputPlugin.cxx @@ -224,16 +224,18 @@ static constexpr Domain curlm_domain("curlm"); * * Runs in the I/O thread. No lock needed. */ +gcc_pure static struct input_curl * input_curl_find_request(CURL *easy) { assert(io_thread_inside()); - for (auto c : curl.requests) - if (c->easy == easy) - return c; + void *p; + CURLcode code = curl_easy_getinfo(easy, CURLINFO_PRIVATE, &p); + if (code != CURLE_OK) + return nullptr; - return nullptr; + return (input_curl *)p; } static void @@ -326,7 +328,6 @@ input_curl_easy_add(struct input_curl *c, Error &error) assert(io_thread_inside()); assert(c != nullptr); assert(c->easy != nullptr); - assert(input_curl_find_request(c->easy) == nullptr); curl.requests.push_front(c); @@ -927,6 +928,7 @@ input_curl_easy_init(struct input_curl *c, Error &error) return false; } + curl_easy_setopt(c->easy, CURLOPT_PRIVATE, (void *)c); curl_easy_setopt(c->easy, CURLOPT_USERAGENT, "Music Player Daemon " VERSION); curl_easy_setopt(c->easy, CURLOPT_HEADERFUNCTION, |