Signals, some are dropped?

Kimmo Hämäläinen kimmo.hamalainen at nokia.com
Fri Feb 2 00:20:04 PST 2007


On Thu, 2007-02-01 at 14:42 -0500, ext Kevin DeKorte wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi All,
> 
> Recently I have written some code that processes signals using the
> lowlevel dbus api. The odd part is that my code does not seem to be
> receiving all the signals sent to it. I can use dbus-send to send the
> same signal and sometimes my code gets it and sometimes it doesn't. It
> is not even one of those cases where it gets 2 and then misses one and
> then gets 2 and misses 1.
> 
> I have a match setup and it calls my signal handler which all it does is
> print the signal info and then exit. I can sent the signal say 5 times
> and the handler will be called only 3 of those times. Is there anything
> I can do to improve this..

Notice that dbus-send is not reliable because of this old bug (because
it's not possible to use --print-reply with signals):
https://bugs.freedesktop.org/show_bug.cgi?id=896

(The daemon should process queued messages before cleaning up the
connection.)

BR; Kimmo

> 
> handler
> 
> static DBusHandlerResult filter_func(DBusConnection * connection,
>                                      DBusMessage * message, void *user_data)
> {
> 
>     const char *sender;
>     const char *destination;
>     int message_type;
>     char *s = NULL;
> 	DBusError error;
> 	
>     message_type = dbus_message_get_type(message);
>     sender = dbus_message_get_sender(message);
>     destination = dbus_message_get_destination(message);
> 	
>     if (message_type == DBUS_MESSAGE_TYPE_SIGNAL) {
>         printf("path=%s; interface=%s; member=%s; data=%s\n",
>                dbus_message_get_path(message),
>                dbus_message_get_interface(message), 		
> dbus_message_get_member(message), s);
> 
>     }
>     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
> }
> 
> 
> how I hook it from a gtk app. I tried dbus-glib but didn't have much
> luck with it.
> 
> 
> gboolean dbus_hookup(gint windowid)
> {
> 
>     DBusConnection *connection;
>     DBusError error;
>     DBusBusType type = DBUS_BUS_SESSION;
>     gchar *match;
> 
>     dbus_error_init(&error);
>     connection = dbus_bus_get(type, &error);
>     if (connection == NULL) {
>         printf("Failed to open connection to %s message bus: %s\n",
>                (type == DBUS_BUS_SYSTEM) ? "system" : "session",
> error.message);
>         dbus_error_free(&error);
>         return FALSE;
>     }
>     dbus_connection_setup_with_g_main(connection, NULL);
> 
> 	match = g_strdup_printf("type='signal',interface='com.my.interface'");
> 	dbus_bus_add_match(connection, match, &error);	
>     printf("Using match: %s\n", match);
>     g_free(match);
> 	
> 	
>     if (!dbus_connection_add_filter(connection, filter_func, NULL, NULL)) {
>         printf("Couldn't add filter!\n");
>         return FALSE;
>     }
> 
>     printf("Proxy connections and Command connected\n");
> 
>     return TRUE;
> }
> 
> 
> I'm using dbus 1.0.1-9 as packaged by Fedora Core 6.
> 
> Thanks,
> 
> Kevin
> - --
> Get my public GnuPG key from
> http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
> 
> iD8DBQFFwkKa6w2kMH0L1dERAuQ5AJ9YY9d3gSpsJ1M9BpqHNkyT2RgR3ACaAwPX
> REDzHh3FKybxcxaOB/wLtMc=
> =SygK
> -----END PGP SIGNATURE-----
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus


More information about the dbus mailing list