Thanks, Havoc. I'll try to get this fixed up for the next release.<br><br>Christian<br><br><br><div><span class="gmail_quote">On 4/24/07, <b class="gmail_sendername">Havoc Pennington</b> <<a href="mailto:hp@redhat.com">
hp@redhat.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>Just reading notification-daemon code, I figured I had better write up
<br>how this pattern is intended to work, I've seen the details wrong in a<br>couple other places too.<br><br>If you want only one instance of the bus name to ever exist, you should<br>do this:<br><br> - support a --replace command line option
<br> - on startup, call dbus_bus_request_name() (or the equivalent with<br> the bindings you are using). Supply the flags<br> DO_NOT_QUEUE, ALLOW_REPLACEMENT, and if --replace was<br> specified, REPLACE_EXISTING
<br> - if you get an error reply (DBusError), exit<br> - if you get a result code other than PRIMARY_OWNER or ALREADY_OWNER,<br> exit<br> - set up a signal handler for the NameLost signal and your bus name,<br> and exit if you receive it. This signal is always sent so it is not
<br> necessary to add a "match rule"<br><br>For most daemons the above is correct. --replace is mostly used for<br>debugging, but may have other uses.<br><br>(notification-daemon developers: the bugs are that you need to check
<br>request_name_result, need to specify ALLOW_REPLACEMENT, need to handle<br>NameLost - I'd file a bug but I'd have to learn Trac ;-)<br><br>If you have a "generic" name and multiple apps supporting it might be
<br>running it at any given time, you might do things differently:<br><br> - use QUEUE mode (pass RequestName flags of 0)<br> - you should always get at least queued for the bus name, so just<br> request it and don't worry about whether you have it at any given
<br> time<br><br>This is appropriate for a name like TextEditor or Browser where another<br>app might want to use "whichever one is open" but it's OK to run two of<br>them at once. Both will be queued for the bus name, the last one to
<br>start will actually own it. If one exits, the other will take over.<br><br>For a name you really want to have only one of, though, such as<br>"Epiphany" rather than "Browser," you should use the first pattern.
<br><br>Havoc<br><br>_______________________________________________<br>dbus mailing list<br><a href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a><br><a href="http://lists.freedesktop.org/mailman/listinfo/dbus">
http://lists.freedesktop.org/mailman/listinfo/dbus</a><br></blockquote></div><br><br clear="all"><br>-- <br>Christian Hammond - <a href="mailto:chipx86@chipx86.com">chipx86@chipx86.com</a><br>VMware, Inc.