After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 559469 - Only first D-Bus message filter gets run if multiple clients are registered
Only first D-Bus message filter gets run if multiple clients are registered
Status: RESOLVED FIXED
Product: gnome-session
Classification: Core
Component: gnome-session
2.24.x
Other All
: Normal normal
: ---
Assigned To: Session Maintainers
Session Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-05 17:02 UTC by Tim Kosse
Modified: 2008-12-08 18:01 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Output of dbus-monitor (2.48 KB, text/plain)
2008-11-05 17:03 UTC, Tim Kosse
  Details
Experimental patch (647 bytes, patch)
2008-11-05 20:23 UTC, Tim Kosse
committed Details | Review

Description Tim Kosse 2008-11-05 17:02:56 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:
Comment 1 Tim Kosse 2008-11-05 17:03:43 UTC
Created attachment 122038 [details]
Output of dbus-monitor
Comment 2 Ray Strode [halfline] 2008-11-05 18:54:58 UTC
Do you have a patch for this issue?
Comment 3 Tim Kosse 2008-11-05 20:23:09 UTC
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.
Comment 4 Tim Kosse 2008-12-05 20:23:35 UTC
Sorry for the noise, but it's been exactly one month since the previous reply.

Is anybody looking into this issue?
Comment 5 Ray Strode [halfline] 2008-12-05 22:52:34 UTC
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.
Comment 6 Ray Strode [halfline] 2008-12-08 18:01:30 UTC
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