From 66dbca1e06af0607a2d0fc6b8d14ef1ebb034f0a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 Jan 2010 20:06:21 +0100 Subject: dbus: remove filter functions only if they were actually set before This fixes an assert when destructing modules that have not been fully initialized. https://bugzilla.redhat.com/show_bug.cgi?id=548525 --- src/pulse/context.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/pulse/context.c') diff --git a/src/pulse/context.c b/src/pulse/context.c index 83e0dbb5..8875bfd8 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -145,7 +145,7 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char * pa_init_i18n(); - c = pa_xnew(pa_context, 1); + c = pa_xnew0(pa_context, 1); PA_REFCNT_INIT(c); c->proplist = p ? pa_proplist_copy(p) : pa_proplist_new(); @@ -157,9 +157,6 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char * c->system_bus = c->session_bus = NULL; #endif c->mainloop = mainloop; - c->client = NULL; - c->pstream = NULL; - c->pdispatch = NULL; c->playback_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); c->record_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); c->client_index = PA_INVALID_INDEX; @@ -170,22 +167,9 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char * c->error = PA_OK; c->state = PA_CONTEXT_UNCONNECTED; - c->ctag = 0; - c->csyncid = 0; reset_callbacks(c); - c->is_local = FALSE; - c->server_list = NULL; - c->server = NULL; - - c->do_shm = FALSE; - - c->server_specified = FALSE; - c->no_fail = FALSE; - c->do_autospawn = FALSE; - memset(&c->spawn_api, 0, sizeof(c->spawn_api)); - #ifndef MSG_NOSIGNAL #ifdef SIGPIPE pa_check_signal_is_blocked(SIGPIPE); @@ -255,12 +239,14 @@ static void context_free(pa_context *c) { #ifdef HAVE_DBUS if (c->system_bus) { - dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->system_bus), filter_cb, c); + if (c->filter_added) + dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->system_bus), filter_cb, c); pa_dbus_wrap_connection_free(c->system_bus); } if (c->session_bus) { - dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->session_bus), filter_cb, c); + if (c->filter_added) + dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->session_bus), filter_cb, c); pa_dbus_wrap_connection_free(c->session_bus); } #endif @@ -794,6 +780,7 @@ static void track_pulseaudio_on_dbus(pa_context *c, DBusBusType type, pa_dbus_wr pa_log_warn("Failed to add filter function"); goto fail; } + c->filter_added = TRUE; if (pa_dbus_add_matches( pa_dbus_wrap_connection_get(*conn), &error, -- cgit