From 8c42d80a53e72d83d8ca788dde4b2aad265110d6 Mon Sep 17 00:00:00 2001 From: javiplx Date: Tue, 5 Oct 2010 00:05:04 +0000 Subject: [PATCH] Fixed stopping of DBUS service git-svn-id: file:///svnroot/wifihood/trunk@20 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscand/wifiscand.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wifiscand/wifiscand.c b/wifiscand/wifiscand.c index 9e9f54e..7351306 100644 --- a/wifiscand/wifiscand.c +++ b/wifiscand/wifiscand.c @@ -295,14 +295,14 @@ gint dbus_req_handler(const gchar * interface, const gchar * method, appdata->iface.sock = 0; #ifdef HAVE_LIBOSSO osso_deinitialize(appdata->osso_context); -#else - dbus_deinitialize(appdata->osso_context); -#endif /* Instead of exiting, signaling finish to main loop could be better retval->value.s = (gchar *) realloc(retval->value.s,34*sizeof(gchar *)); snprintf(retval->value.s,34,"Interface moved to original state"); */ exit(0); +#else + return OSSO_OK; +#endif } if ( strcmp(method,"scan")==0 ) { @@ -335,6 +335,9 @@ gint dbus_req_handler(const gchar * interface, const gchar * method, } #ifndef HAVE_LIBOSSO + +dbus_bool_t stopped_service = FALSE; + static DBusObjectPathVTable *vtable = NULL; int dbus_set_cb_f( DBusConnection *context, @@ -382,6 +385,9 @@ static DBusHandlerResult handler_wrapper (DBusConnection *connection, dbus_message_get_member(message), NULL, data, retval); + if ( strcmp(dbus_message_get_member(message),"stop")==0 ) + stopped_service = TRUE; + if ( retval->value.s != NULL ) { DBusMessage *reply = dbus_message_new_method_return (message); if (reply == NULL) @@ -453,7 +459,7 @@ int main( void ) { event_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(event_loop); #else - while (dbus_connection_read_write_dispatch (osso_context, -1)) {} + while (dbus_connection_read_write_dispatch(osso_context, -1) && stopped_service==FALSE) {} #endif /* Deinitialize OSSO */ -- 1.7.9.5