aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-15 08:20:41 +0200
committerMax Kellermann <max@duempel.org>2011-09-15 09:27:13 +0200
commit28143f86f979bb81e2daf7847b7d5c8dc6ff9886 (patch)
tree40b3f0852ed348defa188425f7e43946c53dfe59
parent76ec3d324815808beaf79b73336ff42e6c0b2b73 (diff)
downloadmpd-28143f86f979bb81e2daf7847b7d5c8dc6ff9886.tar.gz
mpd-28143f86f979bb81e2daf7847b7d5c8dc6ff9886.tar.xz
mpd-28143f86f979bb81e2daf7847b7d5c8dc6ff9886.zip
input/curl: merge _request_abort() into _request_done()
This is a trivial function. Merge some duplicate code, e.g. the g_cond_broadcast() call.
-rw-r--r--src/input/curl_input_plugin.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/src/input/curl_input_plugin.c b/src/input/curl_input_plugin.c
index 560945215..d06125f94 100644
--- a/src/input/curl_input_plugin.c
+++ b/src/input/curl_input_plugin.c
@@ -413,25 +413,6 @@ input_curl_easy_free_indirect(struct input_curl *c)
}
/**
- * Aborts and frees a running HTTP request.
- *
- * The caller must lock the mutex. Runs in the I/O thread.
- */
-static void
-input_curl_request_abort(struct input_curl *c, GError *error)
-{
- assert(c != NULL);
- assert(c->postponed_error == NULL);
- assert(error != NULL);
-
- input_curl_easy_free(c);
-
- c->postponed_error = error;
-
- g_cond_broadcast(curl.cond);
-}
-
-/**
* Abort and free all HTTP requests.
*
* The caller must lock the mutex. Runs in the I/O thread.
@@ -439,12 +420,19 @@ input_curl_request_abort(struct input_curl *c, GError *error)
static void
input_curl_abort_all_requests(GError *error)
{
+ assert(error != NULL);
+
while (curl.requests != NULL) {
- struct input_curl *is = curl.requests->data;
- input_curl_request_abort(is, g_error_copy(error));
+ struct input_curl *c = curl.requests->data;
+ assert(c->postponed_error == NULL);
+
+ input_curl_easy_free(c);
+ c->postponed_error = g_error_copy(error);
}
g_error_free(error);
+
+ g_cond_broadcast(curl.cond);
}
/**
@@ -455,22 +443,22 @@ input_curl_abort_all_requests(GError *error)
static void
input_curl_request_done(struct input_curl *c, CURLcode result, long status)
{
+ assert(c != NULL);
assert(c->easy == NULL);
assert(c->base.ready);
+ assert(c->postponed_error == NULL);
if (result != CURLE_OK) {
- GError *error = g_error_new(curl_quark(), result,
- "curl failed: %s",
- c->error);
- input_curl_request_abort(c, error);
+ c->postponed_error = g_error_new(curl_quark(), result,
+ "curl failed: %s",
+ c->error);
} else if (status < 200 || status >= 300) {
- GError *error = g_error_new(curl_quark(), 0,
- "got HTTP status %ld",
- status);
- input_curl_request_abort(c, error);
- } else {
- g_cond_broadcast(curl.cond);
+ c->postponed_error = g_error_new(curl_quark(), 0,
+ "got HTTP status %ld",
+ status);
}
+
+ g_cond_broadcast(curl.cond);
}
static void