linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [PATCH obexd 6/9] client: terminate queued transfers properly
Date: Tue, 21 Feb 2012 09:46:20 +0100	[thread overview]
Message-ID: <1329813983-26707-7-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1329813983-26707-1-git-send-email-mikel.astiz.oss@gmail.com>

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 |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/client/session.c b/client/session.c
index eaabcf9..50a6a5d 100644
--- a/client/session.c
+++ b/client/session.c
@@ -762,18 +762,34 @@ static void session_terminate_transfer(struct obc_session *session,
 {
 	struct pending_request *p = session->p;
 
-	if (p == NULL || p->transfer != transfer)
-		return;
-
 	obc_session_ref(session);
 
-	if (p->func)
-		p->func(session, gerr, p->data);
+	if (p != NULL && p->transfer == transfer) {
+		if (p->func)
+			p->func(session, gerr, p->data);
 
-	pending_request_free(p);
-	session->p = NULL;
+		pending_request_free(p);
+		session->p = NULL;
 
-	session_process_queue(session);
+		session_process_queue(session);
+	} else {
+		GList *l;
+
+		for (l = session->queue->head; l; l = l->next) {
+			p = l->data;
+
+			if (p->transfer != transfer)
+				continue;
+
+			g_queue_delete_link(session->queue, l);
+
+			if (p->func)
+				p->func(session, gerr, p->data);
+
+			pending_request_free(p);
+			break;
+		}
+	}
 
 	obc_session_unref(session);
 }
-- 
1.7.6.5


  parent reply	other threads:[~2012-02-21  8:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21  8:46 [PATCH obexd 0/9] Transfer cancelation Mikel Astiz
2012-02-21  8:46 ` [PATCH obexd 1/9] gobex: fix callback remove when canceling transfer Mikel Astiz
2012-02-21 11:02   ` Luiz Augusto von Dentz
2012-02-21 11:16     ` Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 2/9] client: fix obc_session_get_buffer Mikel Astiz
2012-02-21 11:07   ` Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 3/9] client: deny cancel when no agent present Mikel Astiz
2012-02-21 11:12   ` Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 4/9] client: remove unnecessary code Mikel Astiz
2012-02-21 11:27   ` Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 5/9] client: process transfer queue only if none active Mikel Astiz
2012-02-21  8:46 ` Mikel Astiz [this message]
2012-02-21 11:40   ` [PATCH obexd 6/9] client: terminate queued transfers properly Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 7/9] client: expose obc_transfer_set_callback Mikel Astiz
2012-02-21 11:51   ` Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 8/9] client: allow cancelling queued transfers Mikel Astiz
2012-02-21 11:56   ` Luiz Augusto von Dentz
2012-02-21  8:46 ` [PATCH obexd 9/9] client: make sure callback does not match size Mikel Astiz

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=1329813983-26707-7-git-send-email-mikel.astiz.oss@gmail.com \
    --to=mikel.astiz.oss@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mikel.astiz@bmw-carit.de \
    /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;
as well as URLs for NNTP newsgroup(s).