From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] obexd/client: Fix not being able cancel GET requests
Date: Thu, 20 Mar 2014 15:50:50 +0200 [thread overview]
Message-ID: <1395323451-31229-2-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1395323451-31229-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In case of GET operation the code does not use g_obex_get_req_pkt since
the beggining to be able to read the header from the first response, this
means that the request should be cancel with g_obex_cancel_req not with
g_obex_cancel_transfer.
---
obexd/client/transfer.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 6295b83..3564a34 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -80,6 +80,7 @@ struct obc_transfer {
char *name; /* Transfer object name */
char *type; /* Transfer object type */
int fd;
+ guint req;
guint xfer;
gint64 size;
gint64 transferred;
@@ -158,6 +159,14 @@ static DBusMessage *obc_transfer_cancel(DBusConnection *connection,
ERROR_INTERFACE ".InProgress",
"Cancellation already in progress");
+ if (transfer->req > 0) {
+ if (!g_obex_cancel_req(transfer->obex, transfer->req, TRUE))
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".Failed",
+ "Failed");
+ transfer->req = 0;
+ }
+
if (transfer->xfer == 0) {
struct transfer_callback *callback = transfer->callback;
@@ -383,6 +392,9 @@ static void obc_transfer_free(struct obc_transfer *transfer)
{
DBG("%p", transfer);
+ if (transfer->req > 0)
+ g_obex_cancel_req(transfer->obex, transfer->req, TRUE);
+
if (transfer->xfer)
g_obex_cancel_transfer(transfer->xfer, NULL, NULL);
@@ -694,6 +706,8 @@ static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp,
transfer->status == TRANSFER_STATUS_SUSPENDED)
return;
+ transfer->req = 0;
+
req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
transfer->xfer = g_obex_get_req_pkt(obex, req, get_xfer_progress,
@@ -783,11 +797,11 @@ static gboolean transfer_start_get(struct obc_transfer *transfer, GError **err)
g_obex_packet_add_header(req, hdr);
}
- transfer->xfer = g_obex_send_req(transfer->obex, req,
+ transfer->req = g_obex_send_req(transfer->obex, req,
FIRST_PACKET_TIMEOUT,
get_xfer_progress_first,
transfer, err);
- if (transfer->xfer == 0)
+ if (transfer->req == 0)
return FALSE;
if (transfer->path == NULL)
--
1.8.5.3
next prev parent reply other threads:[~2014-03-20 13:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-20 13:50 [PATCH BlueZ 1/2] core: Wait for services to be resolved before doing authorization Luiz Augusto von Dentz
2014-03-20 13:50 ` Luiz Augusto von Dentz [this message]
2014-03-20 14:24 ` [PATCH BlueZ] obexd/client: Fix not being able cancel GET requests Johan Hedberg
2014-03-20 13:50 ` [PATCH BlueZ 2/2] core/profile: Remove code for waiting services to be resolved Luiz Augusto von Dentz
2014-03-20 14:24 ` [PATCH BlueZ 1/2] core: Wait for services to be resolved before doing authorization Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395323451-31229-2-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox