All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH obexd v3 0/2] Transfer cancelation
@ 2012-02-27  9:54 Mikel Astiz
  2012-02-27  9:54 ` [PATCH obexd v3 1/2] client: terminate queued transfers properly Mikel Astiz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mikel Astiz @ 2012-02-27  9:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

This patch series proposes several fixes regarding the cancelation of transfers.

This third version includes some minor refactoring of patches v2 5/8 and 7/8, following the reviews from Johan.

Mikel Astiz (2):
  client: terminate queued transfers properly
  client: fix canceling queued transfers

 client/session.c  |   30 ++++++++++++++++++++++++++----
 client/transfer.c |   12 ++++++++----
 2 files changed, 34 insertions(+), 8 deletions(-)

-- 
1.7.6.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH obexd v3 1/2] client: terminate queued transfers properly
  2012-02-27  9:54 [PATCH obexd v3 0/2] Transfer cancelation Mikel Astiz
@ 2012-02-27  9:54 ` Mikel Astiz
  2012-02-27  9:54 ` [PATCH obexd v3 2/2] client: fix canceling queued transfers Mikel Astiz
  2012-02-27 10:40 ` [PATCH obexd v3 0/2] Transfer cancelation Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Mikel Astiz @ 2012-02-27  9:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Previous implementation of session_terminate_transfer assumed that the
transfer being terminated would always be the active one. However, it
should be possible to cancel any queued transfer using the D-Bus api.
---
 client/session.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/client/session.c b/client/session.c
index 30b8431..417295e 100644
--- a/client/session.c
+++ b/client/session.c
@@ -769,14 +769,34 @@ static void session_process_queue(struct obc_session *session)
 	obc_session_unref(session);
 }
 
+static gint pending_transfer_cmptransfer(gconstpointer a, gconstpointer b)
+{
+	const struct pending_request *p = a;
+	const struct obc_transfer *transfer = b;
+
+	if (p->transfer == transfer)
+		return 0;
+
+	return -1;
+}
+
 static void session_terminate_transfer(struct obc_session *session,
 					struct obc_transfer *transfer,
 					GError *gerr)
 {
 	struct pending_request *p = session->p;
 
-	if (p == NULL || p->transfer != transfer)
-		return;
+	if (p == NULL || p->transfer != transfer) {
+		GList *match;
+
+		match = g_list_find_custom(session->queue->head, transfer,
+						pending_transfer_cmptransfer);
+		if (match == NULL)
+			return;
+
+		p = match->data;
+		g_queue_delete_link(session->queue, match);
+	}
 
 	obc_session_ref(session);
 
@@ -784,9 +804,11 @@ static void session_terminate_transfer(struct obc_session *session,
 		p->func(session, gerr, p->data);
 
 	pending_request_free(p);
-	session->p = NULL;
 
-	session_process_queue(session);
+	if (p == session->p) {
+		session->p = NULL;
+		session_process_queue(session);
+	}
 
 	obc_session_unref(session);
 }
-- 
1.7.6.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH obexd v3 2/2] client: fix canceling queued transfers
  2012-02-27  9:54 [PATCH obexd v3 0/2] Transfer cancelation Mikel Astiz
  2012-02-27  9:54 ` [PATCH obexd v3 1/2] client: terminate queued transfers properly Mikel Astiz
@ 2012-02-27  9:54 ` Mikel Astiz
  2012-02-27 10:40 ` [PATCH obexd v3 0/2] Transfer cancelation Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Mikel Astiz @ 2012-02-27  9:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The Cancel() method in the D-Bus api should also abort queued transfers,
which should just be removed from the queue.
---
 client/transfer.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index dded02f..d1edef2 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -143,11 +143,15 @@ static void obc_transfer_abort(struct obc_transfer *transfer)
 {
 	struct transfer_callback *callback = transfer->callback;
 
-	if (transfer->xfer == 0)
-		return;
+	if (transfer->xfer > 0) {
+		g_obex_cancel_transfer(transfer->xfer);
+		transfer->xfer = 0;
+	}
 
-	g_obex_cancel_transfer(transfer->xfer);
-	transfer->xfer = 0;
+	if (transfer->obex != NULL) {
+		g_obex_unref(transfer->obex);
+		transfer->obex = NULL;
+	}
 
 	if (callback) {
 		GError *err;
-- 
1.7.6.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH obexd v3 0/2] Transfer cancelation
  2012-02-27  9:54 [PATCH obexd v3 0/2] Transfer cancelation Mikel Astiz
  2012-02-27  9:54 ` [PATCH obexd v3 1/2] client: terminate queued transfers properly Mikel Astiz
  2012-02-27  9:54 ` [PATCH obexd v3 2/2] client: fix canceling queued transfers Mikel Astiz
@ 2012-02-27 10:40 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2012-02-27 10:40 UTC (permalink / raw)
  To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz

Hi Mikel,

On Mon, Feb 27, 2012, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
> 
> This patch series proposes several fixes regarding the cancelation of
> transfers.
> 
> This third version includes some minor refactoring of patches v2 5/8
> and 7/8, following the reviews from Johan.
> 
> Mikel Astiz (2):
>   client: terminate queued transfers properly
>   client: fix canceling queued transfers
> 
>  client/session.c  |   30 ++++++++++++++++++++++++++----
>  client/transfer.c |   12 ++++++++----
>  2 files changed, 34 insertions(+), 8 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-27 10:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27  9:54 [PATCH obexd v3 0/2] Transfer cancelation Mikel Astiz
2012-02-27  9:54 ` [PATCH obexd v3 1/2] client: terminate queued transfers properly Mikel Astiz
2012-02-27  9:54 ` [PATCH obexd v3 2/2] client: fix canceling queued transfers Mikel Astiz
2012-02-27 10:40 ` [PATCH obexd v3 0/2] Transfer cancelation Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.