* [PATCH obexd] client: fix unreported canceled transfers
@ 2012-02-27 14:14 Mikel Astiz
2012-02-28 12:10 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 2+ messages in thread
From: Mikel Astiz @ 2012-02-27 14:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
A session can be shutted down from D-Bus, and therefore the pending
transfer callbacks must be reported.
---
client/session.c | 15 ++++++++++++++-
client/transfer.c | 4 +---
client/transfer.h | 3 +++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/client/session.c b/client/session.c
index 417295e..f5740ce 100644
--- a/client/session.c
+++ b/client/session.c
@@ -485,12 +485,25 @@ proceed:
void obc_session_shutdown(struct obc_session *session)
{
+ struct pending_request *p;
+ GError *err;
+
DBG("%p", session);
obc_session_ref(session);
/* Unregister any pending transfer */
- g_queue_foreach(session->queue, (GFunc) pending_request_free, NULL);
+ err = g_error_new(OBC_TRANSFER_ERROR, -ECANCELED, "%s",
+ strerror(ECANCELED));
+
+ while ((p = g_queue_pop_head(session->queue))) {
+ if (p->func)
+ p->func(session, err, p->data);
+
+ pending_request_free(p);
+ }
+
+ g_error_free(err);
/* Unregister interfaces */
if (session->path)
diff --git a/client/transfer.c b/client/transfer.c
index d1edef2..4735c17 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -44,8 +44,6 @@
#define DEFAULT_BUFFER_SIZE 4096
-#define OBC_TRANSFER_ERROR obc_transfer_error_quark()
-
static guint64 counter = 0;
struct transfer_callback {
@@ -73,7 +71,7 @@ struct obc_transfer {
int err;
};
-static GQuark obc_transfer_error_quark(void)
+GQuark obc_transfer_error_quark(void)
{
return g_quark_from_static_string("obc-transfer-error-quark");
}
diff --git a/client/transfer.h b/client/transfer.h
index e7e1000..c05e51b 100644
--- a/client/transfer.h
+++ b/client/transfer.h
@@ -21,6 +21,9 @@
*
*/
+#define OBC_TRANSFER_ERROR obc_transfer_error_quark()
+GQuark obc_transfer_error_quark(void);
+
struct obc_transfer_params {
guint8 *data;
size_t size;
--
1.7.6.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH obexd] client: fix unreported canceled transfers
2012-02-27 14:14 [PATCH obexd] client: fix unreported canceled transfers Mikel Astiz
@ 2012-02-28 12:10 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-28 12:10 UTC (permalink / raw)
To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
Hi Mikel,
On Mon, Feb 27, 2012 at 4:14 PM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>
> A session can be shutted down from D-Bus, and therefore the pending
> transfer callbacks must be reported.
> ---
> client/session.c | 15 ++++++++++++++-
> client/transfer.c | 4 +---
> client/transfer.h | 3 +++
> 3 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/client/session.c b/client/session.c
> index 417295e..f5740ce 100644
> --- a/client/session.c
> +++ b/client/session.c
> @@ -485,12 +485,25 @@ proceed:
>
> void obc_session_shutdown(struct obc_session *session)
> {
> + struct pending_request *p;
> + GError *err;
> +
> DBG("%p", session);
>
> obc_session_ref(session);
>
> /* Unregister any pending transfer */
> - g_queue_foreach(session->queue, (GFunc) pending_request_free, NULL);
> + err = g_error_new(OBC_TRANSFER_ERROR, -ECANCELED, "%s",
> + strerror(ECANCELED));
I would use a specific error for this, OBEX_IO_DISCONNECTED or
something like that belongs to session. Btw, session->p should also be
cancelled as well.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-28 12:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-27 14:14 [PATCH obexd] client: fix unreported canceled transfers Mikel Astiz
2012-02-28 12:10 ` Luiz Augusto von Dentz
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).