Skip to contentSkip to conversation

Emit missing signal when data channel is reconnected.

PATCH In review Santiago Carot-Nemesio 2 participants 5 messages Mar 25, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Emit missing signal when data channel is reconnected.

Reconnections of data channels should be indicated to others applications by using the appropriate signal.

---
 health/hdp.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
health/hdp.c +10 -1
index 3c2dce1..b06fe17 100644
@@ -510,14 +510,23 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
 	}
 
 	fd = mcap_mdl_get_fd(dc_data->hdp_chann->mdl);
-	if (fd < 0)
+	if (fd < 0) {
 		reply = g_dbus_create_error(dc_data->msg,
 						ERROR_INTERFACE ".HealthError",
 						"Cannot get file descriptor");
+		g_dbus_send_message(dc_data->conn, reply);
+		return;
+	}
 
 	reply = g_dbus_create_reply(dc_data->msg, DBUS_TYPE_UNIX_FD, &fd,
 							DBUS_TYPE_INVALID);
 	g_dbus_send_message(dc_data->conn, reply);
+
+	g_dbus_emit_signal(dc_data->conn,
+			device_get_path(dc_data->hdp_chann->dev->dev),
+			HEALTH_DEVICE, "ChannelConnected",
+			DBUS_TYPE_OBJECT_PATH,
+			&dc_data->hdp_chann->path, DBUS_TYPE_INVALID);
 }
 
 static void hdp_get_dcpsm_cb(uint16_t dcpsm, gpointer user_data, GError *err)
Signature · 1 line
1.7.4.1
#1 lore raw

Hi,

Quoted 25 lines · Santiago Carot-Nemesio

Reconnections of data channels should be indicated to others applications by using the appropriate signal.

---
 health/hdp.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
health/hdp.c +4 -1
index 3c2dce1..b06fe17 100644
@@ -510,14 +510,23 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
 	}
 
 	fd = mcap_mdl_get_fd(dc_data->hdp_chann->mdl);
-	if (fd < 0)
+	if (fd < 0) {
 		reply = g_dbus_create_error(dc_data->msg,
 						ERROR_INTERFACE ".HealthError",
 						"Cannot get file descriptor");
+		g_dbus_send_message(dc_data->conn, reply);
+		return;
+	}
 
 	reply = g_dbus_create_reply(dc_data->msg, DBUS_TYPE_UNIX_FD, &fd,
 							DBUS_TYPE_INVALID);

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 532

Quoted 10 lines
health/hdp.c +6 -0
 	g_dbus_send_message(dc_data->conn, reply);
+
+	g_dbus_emit_signal(dc_data->conn,
+			device_get_path(dc_data->hdp_chann->dev->dev),
+			HEALTH_DEVICE, "ChannelConnected",
+			DBUS_TYPE_OBJECT_PATH,
+			&dc_data->hdp_chann->path, DBUS_TYPE_INVALID);
 }
 
 static void hdp_get_dcpsm_cb(uint16_t dcpsm, gpointer user_data, GError *err)

Looks like this patch is doing two things:

1. Fix the memory leak/missing g_dbus_send_message call for the return value from g_dbus_create_error.

2. Add sending of the "ChannelConnected" signal.

Could you please split it into two separate patches?

Johan

#2 lore raw

Hi Johan,

See coments below.

2011/3/25 Johan Hedberg <[email protected]>:

Quoted 16 lines

Hi,

Quoted 13 lines · Santiago Carot-Nemesio

Reconnections of data channels should be indicated to others applications by using the appropriate signal.
---
 health/hdp.c |   11 ++++++++++-

 1 files changed, 10 insertions(+), 1 deletions(-)
health/hdp.c +0 -0
index 3c2dce1..b06fe17 100644
@@ -510,14 +510,23 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
       }
 
Quoted 10 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 520

Quoted 10 lines
health/hdp.c +4 -1
       fd = mcap_mdl_get_fd(dc_data->hdp_chann->mdl);
-     if (fd < 0)
+     if (fd < 0) {
               reply = g_dbus_create_error(dc_data->msg,
                                               ERROR_INTERFACE ".HealthError",
                                               "Cannot get file descriptor");
+             g_dbus_send_message(dc_data->conn, reply);
+             return;
+     }
 

This is not a memory leak fix, if fd is less than 0, then reconnection was not succesfully and then we reply with an error response to the application but we dont not emit the CahnnelConnected signal. (return statement).

Quoted 3 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 523

Quoted 3 lines
health/hdp.c +0 -0
       reply = g_dbus_create_reply(dc_data->msg, DBUS_TYPE_UNIX_FD, &fd,
                                                       DBUS_TYPE_INVALID);
       g_dbus_send_message(dc_data->conn, reply);

At this point we have a valid file descriptor and we can send the signal.

Quoted 21 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 532

Quoted 9 lines
health/hdp.c +6 -0
+
+     g_dbus_emit_signal(dc_data->conn,
+                     device_get_path(dc_data->hdp_chann->dev->dev),
+                     HEALTH_DEVICE, "ChannelConnected",
+                     DBUS_TYPE_OBJECT_PATH,
+                     &dc_data->hdp_chann->path, DBUS_TYPE_INVALID);
  }
 
  static void hdp_get_dcpsm_cb(uint16_t dcpsm, gpointer user_data, GError *err)

Looks like this patch is doing two things:

1. Fix the memory leak/missing g_dbus_send_message call for the return value from g_dbus_create_error.

2. Add sending of the "ChannelConnected" signal.

Could you please split it into two separate patches?

Johan

#3 lore raw

Hi,

Quoted 7 lines · Santiago Carot
Quoted 7 lines
Quoted 7 lines
health/hdp.c +0 -0
index 3c2dce1..b06fe17 100644
@@ -510,14 +510,23 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
       }
 
Quoted 15 lines
Quoted 10 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 520

Quoted 10 lines
health/hdp.c +4 -1
       fd = mcap_mdl_get_fd(dc_data->hdp_chann->mdl);
-     if (fd < 0)
+     if (fd < 0) {
               reply = g_dbus_create_error(dc_data->msg,
                                               ERROR_INTERFACE ".HealthError",
                                               "Cannot get file descriptor");
+             g_dbus_send_message(dc_data->conn, reply);
+             return;
+     }
 

This is not a memory leak fix, if fd is less than 0, then reconnection was not succesfully and then we reply with an error response to the application but we dont not emit the CahnnelConnected signal. (return statement).

The code (before your patch) was assigning a value to reply and then right afterwards assigning another value to it without freeing it in between:

Quoted 2 lines
Quoted 2 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 522

Quoted 2 lines
health/hdp.c +0 -0
       reply = g_dbus_create_reply(dc_data->msg, DBUS_TYPE_UNIX_FD, &fd,
                                                       DBUS_TYPE_INVALID);

How is that not a memory leak? (not to mention that g_dbus_send_message isn't called to the error message that you create). Looks to me like there was an "else" statement missing or something similar.

Johan

#4 lore raw

Hi,

2011/3/25 Johan Hedberg <[email protected]>:

Quoted 30 lines

Hi,

Quoted 7 lines · Santiago Carot
Quoted 7 lines
Quoted 7 lines
health/hdp.c +0 -0
index 3c2dce1..b06fe17 100644
@@ -510,14 +510,23 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
       }
 
Quoted 15 lines
Quoted 10 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 520

Quoted 10 lines
health/hdp.c +4 -1
       fd = mcap_mdl_get_fd(dc_data->hdp_chann->mdl);
-     if (fd < 0)
+     if (fd < 0) {
               reply = g_dbus_create_error(dc_data->msg,
                                               ERROR_INTERFACE ".HealthError",
                                               "Cannot get file descriptor");
+             g_dbus_send_message(dc_data->conn, reply);
+             return;
+     }
 

This is not a memory leak fix, if fd is less than 0, then reconnection was not succesfully and then we reply with an error response to the application but we dont not emit the CahnnelConnected signal. (return statement).

The code (before your patch) was assigning a value to reply and then right afterwards assigning another value to it without freeing it in between:

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

health/hdp.c static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data) · line 522

Quoted 2 lines
health/hdp.c +0 -0
       reply = g_dbus_create_reply(dc_data->msg, DBUS_TYPE_UNIX_FD, &fd,
                                                       DBUS_TYPE_INVALID);

How is that not a memory leak? (not to mention that g_dbus_send_message isn't called to the error message that you create). Looks to me like there was an "else" statement missing or something similar.

Sorry,
I didn't understood what you meant. I though that you was referring to the pach but you was referring to the old code. Now I see. You are right, I'm going to split it in two patches right away.