Enlightenment CVS committal Author : raster Project : e17 Module : proto/e_dbus
Dir : e17/proto/e_dbus/src/lib/dbus Modified Files: E_DBus.h e_dbus.c e_dbus_private.h e_dbus_signal.c Log Message: 1. lok's e_dbus patches for hal/volume/storage etc. handling, mounting etc. 2. fixes to dbus signal handlers dont get deleted inside the dbus dispatch loop, but get deferred until later and just marked for deletion (no more segv) =================================================================== RCS file: /cvs/e/e17/proto/e_dbus/src/lib/dbus/E_DBus.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- E_DBus.h 20 Aug 2007 20:26:34 -0000 1.15 +++ E_DBus.h 22 Oct 2007 07:37:15 -0000 1.16 @@ -78,6 +78,7 @@ int e_dbus_signal_init(void); void e_dbus_signal_shutdown(void); E_DBus_Signal_Handler *e_dbus_signal_handler_add(E_DBus_Connection *conn, const char *sender, const char *path, const char *interface, const char *member, E_DBus_Signal_Cb cb_signal, void *data); +void e_dbus_signal_handler_del(E_DBus_Connection *conn, E_DBus_Signal_Handler *sh); /* standard dbus method calls */ =================================================================== RCS file: /cvs/e/e17/proto/e_dbus/src/lib/dbus/e_dbus.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- e_dbus.c 27 Sep 2007 00:44:42 -0000 1.9 +++ e_dbus.c 22 Oct 2007 07:37:15 -0000 1.10 @@ -392,6 +392,7 @@ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } +int _e_dbus_idler_active = 0; static int e_dbus_idler(void *data) @@ -405,10 +406,13 @@ cd->idler = NULL; return 0; } + _e_dbus_idler_active++; dbus_connection_ref(cd->conn); DEBUG(5, "dispatch!\n"); dbus_connection_dispatch(cd->conn); dbus_connection_unref(cd->conn); + _e_dbus_signal_handlers_clean(cd->conn); + _e_dbus_idler_active--; return 1; } =================================================================== RCS file: /cvs/e/e17/proto/e_dbus/src/lib/dbus/e_dbus_private.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_dbus_private.h 20 Aug 2007 20:26:34 -0000 1.4 +++ e_dbus_private.h 22 Oct 2007 07:37:15 -0000 1.5 @@ -29,4 +29,6 @@ int e_dbus_object_init(void); void e_dbus_object_shutdown(void); +extern int _e_dbus_idler_active; + #endif =================================================================== RCS file: /cvs/e/e17/proto/e_dbus/src/lib/dbus/e_dbus_signal.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_dbus_signal.c 25 Jul 2007 17:01:01 -0000 1.5 +++ e_dbus_signal.c 22 Oct 2007 07:37:15 -0000 1.6 @@ -22,6 +22,7 @@ E_DBus_Signal_Cb cb_signal; void *data; + unsigned char delete_me : 1; }; static int cb_signal_event(void *data, int type, void *event); @@ -170,6 +171,56 @@ return sh; } +static int _e_dbus_handler_deletions = 0; + +/** + * Delete a signal handler + * + * @param conn the dbus connection + * @param sh the handler to delete + */ +void +e_dbus_signal_handler_del(E_DBus_Connection *conn, E_DBus_Signal_Handler *sh) +{ + char match[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; + int started = 0; + int len = 0; + DBusError err; + + sh->delete_me = 1; + if (_e_dbus_idler_active) + { + _e_dbus_handler_deletions = 1; + return; + } + if (!ecore_list_goto(signal_handlers, sh)) return; + ecore_list_remove(signal_handlers); + + strcpy(match, "type='signal'"); + len = 13; + +#undef ADD_MATCH_PIECE +#define ADD_MATCH_PIECE(PIECE) \ + if (PIECE) \ + {\ + len += strlen("," #PIECE "=''") + strlen(PIECE);\ + if (len >= sizeof(match)) return;\ + strcat(match, "," #PIECE "='");\ + strcat(match, PIECE);\ + strcat(match, "'");\ + started = 1;\ + } + + ADD_MATCH_PIECE(sh->sender) + ADD_MATCH_PIECE(sh->path) + ADD_MATCH_PIECE(sh->interface) + ADD_MATCH_PIECE(sh->member) + + dbus_bus_remove_match(conn->conn, match, NULL); + + e_dbus_signal_handler_free(sh); +} + static int cb_signal_event(void *data, int type, void *event) { @@ -186,10 +237,23 @@ if (sh->interface && !dbus_message_has_interface(msg, sh->interface)) continue; if (sh->member && !dbus_message_has_member(msg, sh->member)) continue; - sh->cb_signal(sh->data, msg); + if (!sh->delete_me) sh->cb_signal(sh->data, msg); } return 1; } +void +_e_dbus_signal_handlers_clean(E_DBus_Connection *conn) +{ + E_DBus_Signal_Handler *sh; + if (!_e_dbus_handler_deletions) return; + ecore_list_first_goto(signal_handlers); + while ((sh = ecore_list_next(signal_handlers))) + { + if (sh->delete_me) + e_dbus_signal_handler_del(conn, sh); + } + _e_dbus_handler_deletions = 0; +} ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs