From cffc78ad6a978c8ef0afae4fbdd4b189612a7167 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 28 Jan 2013 23:35:01 +0100 Subject: InputStream: store references instead of pointers --- src/input/CurlInputPlugin.cxx | 24 ++++++++++++------------ src/input/RewindInputPlugin.cxx | 2 +- src/input/SoupInputPlugin.cxx | 36 ++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src/input') diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx index 0fbfa29d2..f3edf1dc8 100644 --- a/src/input/CurlInputPlugin.cxx +++ b/src/input/CurlInputPlugin.cxx @@ -462,12 +462,12 @@ input_curl_abort_all_requests(GError *error) input_curl_easy_free(c); - const ScopeLock protect(*c->base.mutex); + const ScopeLock protect(c->base.mutex); c->postponed_error = g_error_copy(error); c->base.ready = true; - c->base.cond->broadcast(); + c->base.cond.broadcast(); } g_error_free(error); @@ -487,7 +487,7 @@ input_curl_request_done(struct input_curl *c, CURLcode result, long status) assert(c->easy == NULL); assert(c->postponed_error == NULL); - const ScopeLock protect(*c->base.mutex); + const ScopeLock protect(c->base.mutex); if (result != CURLE_OK) { c->postponed_error = g_error_new(curl_quark(), result, @@ -501,7 +501,7 @@ input_curl_request_done(struct input_curl *c, CURLcode result, long status) c->base.ready = true; - c->base.cond->broadcast(); + c->base.cond.broadcast(); } static void @@ -735,7 +735,7 @@ static bool fill_buffer(struct input_curl *c, GError **error_r) { while (c->easy != NULL && c->buffers.empty()) - c->base.cond->wait(*c->base.mutex); + c->base.cond.wait(c->base.mutex); if (c->postponed_error != NULL) { g_propagate_error(error_r, c->postponed_error); @@ -855,9 +855,9 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size, is->offset += (goffset)nbytes; if (c->paused && curl_total_buffer_size(c) < CURL_RESUME_AT) { - c->base.mutex->unlock(); + c->base.mutex.unlock(); io_thread_call(input_curl_resume, c); - c->base.mutex->lock(); + c->base.mutex.lock(); } return nbytes; @@ -974,7 +974,7 @@ input_curl_writefunction(void *ptr, size_t size, size_t nmemb, void *stream) if (size == 0) return 0; - const ScopeLock protect(*c->base.mutex); + const ScopeLock protect(c->base.mutex); if (curl_total_buffer_size(c) + size >= CURL_MAX_BUFFERED) { c->paused = true; @@ -984,7 +984,7 @@ input_curl_writefunction(void *ptr, size_t size, size_t nmemb, void *stream) c->buffers.emplace_back(ptr, size); c->base.ready = true; - c->base.cond->broadcast(); + c->base.cond.broadcast(); return size; } @@ -1108,7 +1108,7 @@ input_curl_seek(struct input_stream *is, goffset offset, int whence, /* close the old connection and open a new one */ - c->base.mutex->unlock(); + c->base.mutex.unlock(); input_curl_easy_free_indirect(c); c->buffers.clear(); @@ -1137,10 +1137,10 @@ input_curl_seek(struct input_stream *is, goffset offset, int whence, if (!input_curl_easy_add_indirect(c, error_r)) return false; - c->base.mutex->lock(); + c->base.mutex.lock(); while (!c->base.ready) - c->base.cond->wait(*c->base.mutex); + c->base.cond.wait(c->base.mutex); if (c->postponed_error != NULL) { g_propagate_error(error_r, c->postponed_error); diff --git a/src/input/RewindInputPlugin.cxx b/src/input/RewindInputPlugin.cxx index 6c0093a38..362e55b3f 100644 --- a/src/input/RewindInputPlugin.cxx +++ b/src/input/RewindInputPlugin.cxx @@ -62,7 +62,7 @@ struct RewindInputStream { RewindInputStream(input_stream *_input) :base(rewind_input_plugin, _input->uri, - *_input->mutex, *_input->cond), + _input->mutex, _input->cond), input(_input), tail(0) { } diff --git a/src/input/SoupInputPlugin.cxx b/src/input/SoupInputPlugin.cxx index 6615a3c7f..e9767c20e 100644 --- a/src/input/SoupInputPlugin.cxx +++ b/src/input/SoupInputPlugin.cxx @@ -174,7 +174,7 @@ input_soup_session_callback(G_GNUC_UNUSED SoupSession *session, assert(msg == s->msg); assert(!s->completed); - const ScopeLock protect(*s->base.mutex); + const ScopeLock protect(s->base.mutex); if (!s->base.ready) s->CopyError(msg); @@ -183,7 +183,7 @@ input_soup_session_callback(G_GNUC_UNUSED SoupSession *session, s->alive = false; s->completed = true; - s->base.cond->broadcast(); + s->base.cond.broadcast(); } static void @@ -191,10 +191,10 @@ input_soup_got_headers(SoupMessage *msg, gpointer user_data) { SoupInputStream *s = (SoupInputStream *)user_data; - s->base.mutex->lock(); + s->base.mutex.lock(); if (!s->CopyError(msg)) { - s->base.mutex->unlock(); + s->base.mutex.unlock(); soup_session_cancel_message(soup_session, msg, SOUP_STATUS_CANCELLED); @@ -202,8 +202,8 @@ input_soup_got_headers(SoupMessage *msg, gpointer user_data) } s->base.ready = true; - s->base.cond->broadcast(); - s->base.mutex->unlock(); + s->base.cond.broadcast(); + s->base.mutex.unlock(); soup_message_body_set_accumulate(msg->response_body, false); } @@ -215,7 +215,7 @@ input_soup_got_chunk(SoupMessage *msg, SoupBuffer *chunk, gpointer user_data) assert(msg == s->msg); - const ScopeLock protect(*s->base.mutex); + const ScopeLock protect(s->base.mutex); g_queue_push_tail(s->buffers, soup_buffer_copy(chunk)); s->total_buffered += chunk->length; @@ -225,8 +225,8 @@ input_soup_got_chunk(SoupMessage *msg, SoupBuffer *chunk, gpointer user_data) soup_session_pause_message(soup_session, msg); } - s->base.cond->broadcast(); - s->base.mutex->unlock(); + s->base.cond.broadcast(); + s->base.mutex.unlock(); } static void @@ -236,14 +236,14 @@ input_soup_got_body(G_GNUC_UNUSED SoupMessage *msg, gpointer user_data) assert(msg == s->msg); - const ScopeLock protect(*s->base.mutex); + const ScopeLock protect(s->base.mutex); s->base.ready = true; s->eof = true; s->alive = false; - s->base.cond->broadcast(); - s->base.mutex->unlock(); + s->base.cond.broadcast(); + s->base.mutex.unlock(); } inline bool @@ -261,7 +261,7 @@ SoupInputStream::WaitData() assert(current_consumed == 0); - base.cond->wait(*base.mutex); + base.cond.wait(base.mutex); } } @@ -339,22 +339,22 @@ input_soup_cancel(gpointer data) SoupInputStream::~SoupInputStream() { - base.mutex->lock(); + base.mutex.lock(); if (!completed) { /* the messages's session callback hasn't been invoked yet; cancel it and wait for completion */ - base.mutex->unlock(); + base.mutex.unlock(); io_thread_call(input_soup_cancel, this); - base.mutex->lock(); + base.mutex.lock(); while (!completed) - base.cond->wait(*base.mutex); + base.cond.wait(base.mutex); } - base.mutex->unlock(); + base.mutex.unlock(); SoupBuffer *buffer; while ((buffer = (SoupBuffer *)g_queue_pop_head(buffers)) != NULL) -- cgit v1.2.3