aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--NEWS2
-rw-r--r--src/input_curl.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 93c4d5965..0753091e9 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ MPD 0.14.1 - not yet released
* update:
- refresh stats after update
- save the database even if it is empty
+* input_curl:
+ - use select() to eliminate busy loop during connect
* log: automatically append newline
* fix setenv() conflict on Solaris
* configure.ac: check for pkg-config before using it
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));