[PATCH 48/60] Notify MCL closed when there is a pending callback

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

 



From: José Antonio Santos-Cadenas <santoscadenas@xxxxxxxxx>

---
 mcap/mcap.c     |   11 ++++++++++-
 mcap/mcap_lib.h |    1 +
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/mcap/mcap.c b/mcap/mcap.c
index f164e76..434d50f 100644
--- a/mcap/mcap.c
+++ b/mcap/mcap.c
@@ -1643,6 +1643,7 @@ void mcap_mdl_connect(struct mcap_mdl *mdl, BtIOType BtType, uint16_t dcpsm,
 static gboolean mcl_control_cb(GIOChannel *chan, GIOCondition cond,
 								gpointer data)
 {
+	GError *gerr = NULL;
 
 	struct mcap_mcl *mcl = data;
 	int sk, len;
@@ -1659,8 +1660,16 @@ static gboolean mcl_control_cb(GIOChannel *chan, GIOCondition cond,
 	proc_cmd(mcl, buf, (uint32_t)len);
 	return TRUE;
 fail:
-	if (mcl->state != MCL_IDLE)
+	if (mcl->state != MCL_IDLE) {
+		if (mcl->req == MCL_WAITING_RSP) {
+			/* notify error in pending callback */
+			g_set_error(&gerr, MCAP_ERROR, MCAP_ERROR_MCL_CLOSED,
+								"MCL closed");
+			mcap_notify_error(mcl, gerr, TRUE);
+			g_error_free(gerr);
+		}
 		mcl->ms->mcl_disconnected_cb(mcl, mcl->ms->user_data);
+	}
 	mcap_cache_mcl(mcl);
 	return FALSE;
 }
diff --git a/mcap/mcap_lib.h b/mcap/mcap_lib.h
index 67c2f29..afac8aa 100644
--- a/mcap/mcap_lib.h
+++ b/mcap/mcap_lib.h
@@ -52,6 +52,7 @@ typedef enum {
 	MCAP_ERROR_INVALID_ARGS,
 	MCAP_ERROR_ALREADY_EXISTS,
 	MCAP_ERROR_REQ_IGNORED,
+	MCAP_ERROR_MCL_CLOSED,
 	MCAP_ERROR_FAILED
 } McapError;
 
-- 
1.6.3.3

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