summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-03-17 13:33:28 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-03-17 13:33:28 +0000
commitfb68b88c38aadd308773ce7e13c8915be5ee0a04 (patch)
tree72a4aa4f0bc3c3ce5f280b49aeb9d316649014af /hcid
parentf2c79770258ca61450e541a42154bbcea90fd0b0 (diff)
Fixed request name: allow only one instance of the daemon running
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 31ca507c..919f7456 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -47,10 +47,6 @@
#include "textfile.h"
#include "list.h"
-#ifndef DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT
-#define DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT 0x00
-#endif
-
static DBusConnection *connection;
static int default_dev = -1;
@@ -1144,6 +1140,7 @@ static void watch_toggled(DBusWatch *watch, void *data)
gboolean hcid_dbus_init(void)
{
+ int ret_val;
DBusError err;
dbus_error_init(&err);
@@ -1158,8 +1155,13 @@ gboolean hcid_dbus_init(void)
dbus_connection_set_exit_on_disconnect(connection, FALSE);
- dbus_bus_request_name(connection, BASE_INTERFACE,
- DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT, &err);
+ ret_val = dbus_bus_request_name(connection, BASE_INTERFACE,
+ 0, &err);
+
+ if (ret_val != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ) {
+ error("Service could not become the primary owner.");
+ return FALSE;
+ }
if (dbus_error_is_set(&err)) {
error("Can't get system message bus name: %s", err.message);