aboutsummaryrefslogtreecommitdiffstats
path: root/src/input_curl.c
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 23:10:15 +0100
commit159d0858d1b041df2c367d69fd41231f95efa179 (patch)
tree6248270fe2be192ccb43e5551f4ddf37ab1c08c6 /src/input_curl.c
parent7beab74d87cb05d19725da17dc5fe7cc70d383e6 (diff)
downloadmpd-159d0858d1b041df2c367d69fd41231f95efa179.tar.gz
mpd-159d0858d1b041df2c367d69fd41231f95efa179.tar.xz
mpd-159d0858d1b041df2c367d69fd41231f95efa179.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 'src/input_curl.c')
-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 eb2550c6d..20d03222a 100644
--- a/src/input_curl.c
+++ b/src/input_curl.c
@@ -344,6 +344,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 && list_empty(&c->buffers));