[yelp/yelp-3-0] [libyelp] Various race conditions and premature frees fixed.
- From: Shaun McCance <shaunm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [yelp/yelp-3-0] [libyelp] Various race conditions and premature frees fixed.
- Date: Sun, 15 Nov 2009 22:37:07 +0000 (UTC)
commit f3bc727b75592bdee2a3b09ac32259994752ddfc
Author: Shaun McCance <shaunm gnome org>
Date: Tue Oct 27 01:00:58 2009 -0500
[libyelp] Various race conditions and premature frees fixed.
It's hard, but not impossible, for a human to trigger these under normal
circumstances. I know there's at least one more hiding somewhere. Try
double-clicking links.
libyelp/yelp-mallard-document.c | 3 +++
libyelp/yelp-transform.c | 5 ++++-
libyelp/yelp-uri.c | 5 ++++-
tests/test-view.c | 11 ++++++++++-
4 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/libyelp/yelp-mallard-document.c b/libyelp/yelp-mallard-document.c
index 1381cfc..6afb5d1 100644
--- a/libyelp/yelp-mallard-document.c
+++ b/libyelp/yelp-mallard-document.c
@@ -536,7 +536,10 @@ mallard_page_data_run (MallardPageData *page_data)
YelpMallardDocumentPrivate *priv = GET_PRIV (page_data->mallard);
gint i, ix;
gchar **params = NULL;
+
+ mallard_page_data_cancel (page_data);
page_data->transform = yelp_transform_new ();
+
/* FIXME: handle error */
yelp_transform_set_stylesheet (page_data->transform, STYLESHEET, NULL);
diff --git a/libyelp/yelp-transform.c b/libyelp/yelp-transform.c
index abf77ac..b337e74 100644
--- a/libyelp/yelp-transform.c
+++ b/libyelp/yelp-transform.c
@@ -180,6 +180,8 @@ yelp_transform_finalize (GObject *object)
YelpTransformPrivate *priv = GET_PRIV (object);
xsltDocumentPtr xsltdoc;
+ debug_print (DB_FUNCTION, "entering\n");
+
if (priv->output)
xmlFreeDoc (priv->output);
if (priv->stylesheet)
@@ -346,11 +348,12 @@ transform_run (YelpTransform *transform)
priv->running = FALSE;
if (!priv->cancelled) {
g_idle_add ((GSourceFunc) transform_final, transform);
+ g_mutex_unlock (priv->mutex);
}
else {
+ g_mutex_unlock (priv->mutex);
g_object_unref (transform);
}
- g_mutex_unlock (priv->mutex);
}
static gboolean
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c
index 605f30b..e1d808b 100644
--- a/libyelp/yelp-uri.c
+++ b/libyelp/yelp-uri.c
@@ -235,9 +235,11 @@ resolve_start (YelpUri *uri)
{
YelpUriPrivate *priv = GET_PRIV (uri);
- if (priv->resolver == NULL)
+ if (priv->resolver == NULL) {
+ g_object_ref (uri);
priv->resolver = g_thread_create ((GThreadFunc) resolve_async,
uri, FALSE, NULL);
+ }
}
static void
@@ -330,6 +332,7 @@ resolve_final (YelpUri *uri)
}
g_signal_emit (uri, uri_signals[RESOLVED], 0);
+ g_object_unref (uri);
return FALSE;
}
diff --git a/tests/test-view.c b/tests/test-view.c
index 57897bc..3858e37 100644
--- a/tests/test-view.c
+++ b/tests/test-view.c
@@ -32,6 +32,10 @@ static void
activate_cb (GtkEntry *entry,
YelpView *view)
{
+ /* I put in the double-load to test some race condition bugs.
+ * I decided to leave it in.
+ */
+ yelp_view_load (view, gtk_entry_get_text (entry));
yelp_view_load (view, gtk_entry_get_text (entry));
}
@@ -83,8 +87,13 @@ main (int argc, char **argv)
g_signal_connect (entry, "activate", activate_cb, view);
- if (argc >= 2)
+ if (argc >= 2) {
+ /* I put in the double-load to test some race condition bugs.
+ * I decided to leave it in.
+ */
+ yelp_view_load (view, argv[1]);
yelp_view_load (view, argv[1]);
+ }
gtk_widget_show_all (GTK_WIDGET (window));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]