aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-06-06 15:19:24 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-07-02 13:48:05 +0300
commit1ebe9d3e670008ce419917f4120fab0f5e642628 (patch)
tree236458c01900645d0ffee3ec83b0018b235b3c38
parent57ccf8d6d6d66b710270c0b7b71d9a1128aab3fc (diff)
downloadbluez-1ebe9d3e670008ce419917f4120fab0f5e642628.tar.gz
bluez-1ebe9d3e670008ce419917f4120fab0f5e642628.tar.xz
bluez-1ebe9d3e670008ce419917f4120fab0f5e642628.zip
sap-dummy: Fix initialization if multiple adapters are present
sap-dummy is a SAP server backend so its init function is called for each adapter registered and not only on start. Without this patch sap-dummy interface was only registered for first adapter.
-rw-r--r--sap/sap-dummy.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sap/sap-dummy.c b/sap/sap-dummy.c
index 2ad8af4d..dab5acc0 100644
--- a/sap/sap-dummy.c
+++ b/sap/sap-dummy.c
@@ -43,6 +43,7 @@ enum {
};
static DBusConnection *connection = NULL;
+static unsigned int init_cnt = 0;
static int sim_card_conn_status = SIM_DISCONNECTED;
static void *sap_data = NULL; /* SAP server private data. */
@@ -355,6 +356,9 @@ static const GDBusMethodTable dummy_methods[] = {
int sap_init(void)
{
+ if (init_cnt++)
+ return 0;
+
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (g_dbus_register_interface(connection, SAP_DUMMY_PATH,
@@ -362,8 +366,11 @@ int sap_init(void)
NULL, NULL) == FALSE) {
error("sap-dummy interface %s init failed on path %s",
SAP_DUMMY_IFACE, SAP_DUMMY_PATH);
- dbus_connection_unref(connection);
- connection = NULL;
+
+ if (init_cnt--) {
+ dbus_connection_unref(connection);
+ connection = NULL;
+ }
return -1;
}
@@ -372,6 +379,9 @@ int sap_init(void)
void sap_exit(void)
{
+ if (--init_cnt)
+ return;
+
g_dbus_unregister_interface(connection, SAP_DUMMY_PATH,
SAP_DUMMY_IFACE);