diff options
author | Max Kellermann <max@duempel.org> | 2011-09-16 20:34:42 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-16 20:34:47 +0200 |
commit | 65dfd90141e51d896e0988fe3c6afd3d3f9d7460 (patch) | |
tree | b39e7113189386859b7711ac3d7992d91f399e12 | |
parent | 59abdbd2dd820069e1ca25e3c44c1b02f906087b (diff) | |
download | mpd-65dfd90141e51d896e0988fe3c6afd3d3f9d7460.tar.gz mpd-65dfd90141e51d896e0988fe3c6afd3d3f9d7460.tar.xz mpd-65dfd90141e51d896e0988fe3c6afd3d3f9d7460.zip |
input/soup: move libsoup calls to the I/O thread
libsoup's asynchronous API is not thread safe. By moving the calls
into the I/O thread, several crash bugs will be fixed.
Diffstat (limited to '')
-rw-r--r-- | src/input/soup_input_plugin.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/input/soup_input_plugin.c b/src/input/soup_input_plugin.c index 7f92113b4..12ede3a29 100644 --- a/src/input/soup_input_plugin.c +++ b/src/input/soup_input_plugin.c @@ -220,6 +220,17 @@ input_soup_wait_data(struct input_soup *s) } } +static gpointer +input_soup_queue(gpointer data) +{ + struct input_soup *s = data; + + soup_session_queue_message(soup_session, s->msg, + input_soup_session_callback, s); + + return NULL; +} + static struct input_stream * input_soup_open(const char *uri, G_GNUC_UNUSED GError **error_r) { @@ -255,12 +266,23 @@ input_soup_open(const char *uri, G_GNUC_UNUSED GError **error_r) s->completed = false; s->postponed_error = NULL; - soup_session_queue_message(soup_session, s->msg, - input_soup_session_callback, s); + io_thread_call(input_soup_queue, s); return &s->base; } +static gpointer +input_soup_cancel(gpointer data) +{ + struct input_soup *s = data; + + if (!s->completed) + soup_session_cancel_message(soup_session, s->msg, + SOUP_STATUS_CANCELLED); + + return NULL; +} + static void input_soup_close(struct input_stream *is) { @@ -274,8 +296,7 @@ input_soup_close(struct input_stream *is) g_mutex_unlock(s->mutex); - soup_session_cancel_message(soup_session, s->msg, - SOUP_STATUS_CANCELLED); + io_thread_call(input_soup_cancel, s); g_mutex_lock(s->mutex); while (!s->completed) |