[PATCH 37/60] Remove MDL when delete operation fails with INVALID_MDL response code

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

 



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

---
 mcap/mcap.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/mcap/mcap.c b/mcap/mcap.c
index 63058d1..87aa233 100644
--- a/mcap/mcap.c
+++ b/mcap/mcap.c
@@ -1385,6 +1385,7 @@ static gboolean process_md_delete_mdl_rsp(struct mcap_mcl *mcl, uint8_t *cmd,
 	gpointer user_data = del->user_data;
 	mcap_md_req *cmdlast = (mcap_md_req *) mcl->lcmd;
 	uint16_t mdlid = ntohs(cmdlast->mdl);
+	mcap4B_rsp *rsp = (mcap4B_rsp *)cmd;
 	GError *gerr = NULL;
 	gboolean close = FALSE;
 	gboolean notify = FALSE;
@@ -1397,14 +1398,20 @@ static gboolean process_md_delete_mdl_rsp(struct mcap_mcl *mcl, uint8_t *cmd,
 	g_free(mcl->lcmd);
 	mcl->lcmd = NULL;
 	mcl->req = MCL_AVAILABLE;
+
 	if (gerr) {
-		if (mdl)
-			restore_mdl(mdl, NULL);
-		else
+		if (!mdl) {
+			/* Deletion of all mdls failed */
 			g_slist_foreach(mcl->mdls, restore_mdl, NULL);
-		deleted_cb(gerr, user_data);
-		g_error_free(gerr);
-		return close;
+		} else if ((len >= MIN_RSP_LEN) &&
+						(rsp->rc == MCAP_INVALID_MDL)) {
+			/* Mdl does not exist in remote side */
+			goto del_mdl;
+		} else {
+			/* this mdl couldn't be deleted */
+			restore_mdl(mdl, NULL);
+		}
+		goto end;
 	}
 
 	if (mdlid == MCAP_ALL_MDLIDS) {
@@ -1414,12 +1421,14 @@ static gboolean process_md_delete_mdl_rsp(struct mcap_mcl *mcl, uint8_t *cmd,
 		mcl->state = MCL_CONNECTED;
 		goto end;
 	}
-
+del_mdl:
 	mcl->mdls = g_slist_remove(mcl->mdls, mdl);
 	update_mcl_state(mcl);
 	mcap_delete_mdl(mdl, &notify);
 end:
 	deleted_cb(gerr, user_data);
+	if (gerr)
+		g_error_free(gerr);
 	return close;
 }
 
-- 
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