[glib] GThreadedResolver: don't overwrite errors
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GThreadedResolver: don't overwrite errors
- Date: Tue, 20 Sep 2011 21:01:15 +0000 (UTC)
commit 855e13cc0acadd9d87baf55a2dd9a50e721ec6b1
Author: Dan Winship <danw gnome org>
Date: Tue Sep 20 16:58:34 2011 -0400
GThreadedResolver: don't overwrite errors
If a dns op was cancelled and then the abandoned op failed, it would
try to overwrite the original error. Fix that.
https://bugzilla.gnome.org/show_bug.cgi?id=658769
gio/gthreadedresolver.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c
index 7412bcd..2e6f18d 100644
--- a/gio/gthreadedresolver.c
+++ b/gio/gthreadedresolver.c
@@ -233,7 +233,7 @@ g_threaded_resolver_request_unref (GThreadedResolverRequest *req)
static void
g_threaded_resolver_request_complete (GThreadedResolverRequest *req,
- gboolean cancelled)
+ GError *error)
{
g_mutex_lock (req->mutex);
if (req->complete)
@@ -242,18 +242,18 @@ g_threaded_resolver_request_complete (GThreadedResolverRequest *req,
* well. But we have nowhere to send the result, so just return.
*/
g_mutex_unlock (req->mutex);
+ g_clear_error (&error);
return;
}
req->complete = TRUE;
g_mutex_unlock (req->mutex);
+ if (error)
+ g_propagate_error (&req->error, error);
+
if (req->cancellable)
{
- /* Possibly propagate a cancellation error */
- if (cancelled && !req->error)
- g_cancellable_set_error_if_cancelled (req->cancellable, &req->error);
-
/* Drop the signal handler's ref on @req */
g_signal_handlers_disconnect_by_func (req->cancellable, request_cancelled, req);
g_object_unref (req->cancellable);
@@ -281,8 +281,10 @@ request_cancelled (GCancellable *cancellable,
gpointer user_data)
{
GThreadedResolverRequest *req = user_data;
+ GError *error = NULL;
- g_threaded_resolver_request_complete (req, TRUE);
+ g_cancellable_set_error_if_cancelled (req->cancellable, &error);
+ g_threaded_resolver_request_complete (req, error);
/* We can't actually cancel the resolver thread; it will eventually
* complete on its own and call request_complete() again, which will
@@ -302,9 +304,10 @@ threaded_resolver_thread (gpointer thread_data,
gpointer pool_data)
{
GThreadedResolverRequest *req = thread_data;
+ GError *error = NULL;
- req->resolve_func (req, &req->error);
- g_threaded_resolver_request_complete (req, FALSE);
+ req->resolve_func (req, &error);
+ g_threaded_resolver_request_complete (req, error);
g_threaded_resolver_request_unref (req);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]