[PATCH 5/7] sap: disconnect RFCOMM when Disconnect gets called

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

 



From: Claudio Takahasi <claudio.takahasi@xxxxxxxxxxxxx>

---
 sap/client.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/sap/client.c b/sap/client.c
index 435a82f..93ba54d 100644
--- a/sap/client.c
+++ b/sap/client.c
@@ -121,6 +121,24 @@ static void change_state(struct client *client, int new_state)
 			DBUS_TYPE_STRING, &val);
 }
 
+static gboolean disconnect_rfcomm(gpointer data)
+{
+	struct client *client = data;
+	int sock;
+
+	if (!client->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(client->io);
+	shutdown(sock, SHUT_RDWR);
+
+	g_io_channel_unref(client->io);
+	g_io_channel_shutdown(client->io, TRUE, NULL);
+	client->io = NULL;
+
+	return FALSE;
+}
+
 static gboolean rfcomm_io(GIOChannel *io, GIOCondition cond, gpointer data)
 {
 	struct client *client = data;
@@ -230,7 +248,7 @@ static DBusMessage *client_disconnect(DBusConnection *conn,
 	if (client->msg)
 		return btd_error_in_progress(msg);
 
-	 /* TODO: exit from remote SIM mode */
+	disconnect_rfcomm(client);
 
 	return dbus_message_new_method_return(msg);
 }
-- 
1.7.6

--
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