aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-13 19:30:34 +0100
committerMax Kellermann <max@duempel.org>2009-01-13 19:30:34 +0100
commite7c7e652a33ee143d183d8ba1916fe1bf0f3a980 (patch)
tree0d33bde2cf845bcd54db7ad91b7a54a3a1faa99b /src
parentd82061b7ff19413985ad34690b2bd169bc2f3651 (diff)
downloadmpd-e7c7e652a33ee143d183d8ba1916fe1bf0f3a980.tar.gz
mpd-e7c7e652a33ee143d183d8ba1916fe1bf0f3a980.tar.xz
mpd-e7c7e652a33ee143d183d8ba1916fe1bf0f3a980.zip
input_curl: use select() to eliminate busy loop during connect
When decoder_run_song() (decoder_thread.c) waits for the input stream to become ready, it did that in a busy loop. Add a select() call to input_curl_buffer() during connect/handshake (i.e. before the first chunk of body data was received), to let the CPU relax.
Diffstat (limited to '')
-rw-r--r--src/input_curl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/input_curl.c b/src/input_curl.c
index f86386522..d9655fc62 100644
--- a/src/input_curl.c
+++ b/src/input_curl.c
@@ -470,6 +470,12 @@ input_curl_buffer(struct input_stream *is)
c->buffered = false;
+ if (!is->ready)
+ /* not ready yet means the caller is waiting in a busy
+ loop; relax that by calling select() on the
+ socket */
+ input_curl_select(c);
+
do {
mcode = curl_multi_perform(c->multi, &running_handles);
} while (mcode == CURLM_CALL_MULTI_PERFORM &&