Skip to contentSkip to conversation

obexd/client: Fix calling g_obex_cancel_req for completed requests

PATCH In review Luiz Augusto von Dentz 1 participant 3 messages Apr 7, 2014 – Apr 8, 2014 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 obexd/client: Fix calling g_obex_cancel_req for completed requests

From: Luiz Augusto von Dentz <[email protected]>

This leads to incorrect responses such as the following:

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 26

    L2CAP(d): cid 0x0041 len 22 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 38 pf 0 ilen 18 fcs 0xfd
        OBEX: Get rsp(f): status 200 len 18
        Status 200 = Success
        Connection ID (0xcb) = 1
        App. Parameters (0x4c) = Sequence length 4
        End of Body (0x49) = Sequence length 0
< ACL data: handle 12 flags 0x00 dlen 11
    L2CAP(d): cid 0x0040 len 7 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 38 pf 0 ilen 3 fcs 0x27
        OBEX: Get rsp(f): status 715 len 3
---
 obexd/client/transfer.c | 1 +
 1 file changed, 1 insertion(+)
obexd/client/transfer.c +1 -0
index 3564a34..bd2b1ab 100644
@@ -698,6 +698,7 @@ static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
 	}
 
 	if (rspcode == G_OBEX_RSP_SUCCESS) {
+		transfer->req = 0;
 		xfer_complete(obex, err, transfer);
 		return;
 	}
Signature · 1 line
1.9.0
author maintainer
#1 lore raw

PATCH 2/2 gobex: Fix being able to cancel completed requests

From: Luiz Augusto von Dentz <[email protected]>

This fixes bogus responses when rsp_func calls g_obex_cancel_req for responses with final bit set.

---
 gobex/gobex.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
gobex/gobex.c +5 -3
index 7f85938..850e288 100644
@@ -1098,6 +1098,10 @@ static void handle_response(GObex *obex, GError *err, GObexPacket *rsp)
 
 	p = obex->pending_req;
 
+	/* Reset if final so it can no longer be cancelled */
+	if (final_rsp)
+		obex->pending_req = NULL;
+
 	if (p->cancelled)
 		err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED,
 					"The operation was cancelled");
@@ -1116,10 +1120,8 @@ static void handle_response(GObex *obex, GError *err, GObexPacket *rsp)
 	if (p->cancelled)
 		g_error_free(err);
 
-	if (final_rsp) {
+	if (final_rsp)
 		pending_pkt_free(p);
-		obex->pending_req = NULL;
-	}
 
 	if (!disconn && g_queue_get_length(obex->tx_queue) > 0)
 		enable_tx(obex);
Signature · 1 line
1.9.0
author maintainer
#2 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 33 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This leads to incorrect responses such as the following:

Quoted 1 line

ACL data: handle 12 flags 0x02 dlen 26

    L2CAP(d): cid 0x0041 len 22 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 38 pf 0 ilen 18 fcs 0xfd
        OBEX: Get rsp(f): status 200 len 18
        Status 200 = Success
        Connection ID (0xcb) = 1
        App. Parameters (0x4c) = Sequence length 4
        End of Body (0x49) = Sequence length 0
< ACL data: handle 12 flags 0x00 dlen 11
    L2CAP(d): cid 0x0040 len 7 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 38 pf 0 ilen 3 fcs 0x27
        OBEX: Get rsp(f): status 715 len 3
---
 obexd/client/transfer.c | 1 +
 1 file changed, 1 insertion(+)
obexd/client/transfer.c +1 -1
index 3564a34..bd2b1ab 100644
@@ -698,6 +698,7 @@ static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
        }
 
        if (rspcode == G_OBEX_RSP_SUCCESS) {
+               transfer->req = 0;
                xfer_complete(obex, err, transfer);
                return;
        }
--
Quoted 1 line

1.9.0

Pushed.

Signature · 1 line
Luiz Augusto von Dentz