[PATCH 2/4] android/health: Add channel_notify for incoming connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

For other then ECHO mdep send send_channel_state_notify with fd.
---
 android/health.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/android/health.c b/android/health.c
index 2b8562f..e088ec7 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1136,25 +1136,36 @@ static gboolean serve_echo(GIOChannel *io, GIOCondition cond, gpointer data)
 static void mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
 {
 	struct health_channel *channel = data;
+	int fd;
 
 	if (!channel->mdl)
 		channel->mdl = mcap_mdl_ref(mdl);
 
 	DBG("Data channel connected: mdl %p channel %p", mdl, channel);
 
+	fd = mcap_mdl_get_fd(channel->mdl);
+	if (fd < 0) {
+		error("health: error retrieving fd");
+		goto fail;
+	}
+
 	if (channel->mdep_id == MDEP_ECHO) {
 		GIOChannel *io;
-		int fd;
-
-		fd = mcap_mdl_get_fd(channel->mdl);
-		if (fd < 0)
-			return;
 
 		io = g_io_channel_unix_new(fd);
 		g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_IN,
 							serve_echo, channel);
 		g_io_channel_unref(io);
+
+		return;
 	}
+
+	send_channel_state_notify(channel, HAL_HEALTH_CHANNEL_CONNECTED, fd);
+
+	return;
+fail:
+	/* TODO: mcap_mdl_abort */
+	destroy_channel(channel);
 }
 
 static void mcap_mdl_closed_cb(struct mcap_mdl *mdl, void *data)
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux