GNOME Bugzilla – Bug 559469
Only first D-Bus message filter gets run if multiple clients are registered
Last modified: 2008-12-08 18:01:30 UTC
Please describe the problem: I've written some code so that my program uses the D-Bus API of the session manager so that it can gracefully shutdown itself when the session ends. It works fine if I have it started a single time, but fails if I have multiple instances of my program open. The attached output of dbus-monitor shows that both clients register themselves successfully and both receive the QueryEndSession signal and reply to it. However, the second call to the EndSessionResponse method always fails for the second client. I think the cause of this problem is entirely in GNOME's gsm-dbus-client.c For each registered client, a dbus message filter is installed in gsm_dbus_client_constructor. AFAIK the same connection is used for each client. So when a client calls EndSessionResponse, all filters get executed in order until one returns DBUS_HANDLER_RESULT_HANDLED. The problem is that client_dbus_filter_function always calls handle_end_session_response and returns DBUS_HANDLER_RESULT_HANDLED, even if the client and the sender do not match, resulting in "Caller not recognized as the client". Correct behavior would be to return DBUS_HANDLER_RESULT_NOT_YET_HANDLED if client and sender do not match and only reply with "Caller not recognized as the client" if no handler accepted. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 122038 [details] Output of dbus-monitor
Do you have a patch for this issue?
Created attachment 122058 [details] [review] Experimental patch I've come up with this experimental patch. It seems to work fine, made my problems go away. No idea if it is the correct thing to do though.
Sorry for the noise, but it's been exactly one month since the previous reply. Is anybody looking into this issue?
Patch looks reasonable to me (sans the C++ style comment which doesn't match the coding style). I believe this is Jon's code though, so it'd probably be best if he chimed in.
Talked to Jon about this. He thinks the patch makes sense modulo some style issues. Thanks! I've commited this: http://svn.gnome.org/viewvc/gnome-session?view=revision&revision=5163