All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix not detecting errors on small files
@ 2010-09-29 14:27 Luiz Augusto von Dentz
  2010-09-29 20:26 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2010-09-29 14:27 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

When flushing the last part of buffer/file we have to wait for response
since that can contain errors.

To fix this gw_obex_xfer_close is called in order to force gwobex to
resume the request and return any error related to it.
---
 client/transfer.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index 8ceb36f..e5fcfcc 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -360,7 +360,7 @@ static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data)
 {
 	struct transfer_data *transfer = user_data;
 	struct transfer_callback *callback = transfer->callback;
-	gint written, err = 0;
+	gint written = 0, err = 0;
 
 	if (transfer->buffer_len == 0) {
 		transfer->buffer_len = DEFAULT_BUFFER_SIZE;
@@ -380,7 +380,12 @@ static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data)
 		transfer->filled += len;
 
 		if (transfer->filled == 0) {
-			gw_obex_xfer_flush(xfer, &err);
+			if (written > 0) {
+				gw_obex_xfer_flush(xfer, &err);
+				return;
+			}
+
+			gw_obex_xfer_close(xfer, &err);
 			goto done;
 		}
 
-- 
1.7.1


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

* Re: [PATCH] Fix not detecting errors on small files
  2010-09-29 14:27 [PATCH] Fix not detecting errors on small files Luiz Augusto von Dentz
@ 2010-09-29 20:26 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2010-09-29 20:26 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Wed, Sep 29, 2010 at 5:27 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>
> When flushing the last part of buffer/file we have to wait for response
> since that can contain errors.
>
> To fix this gw_obex_xfer_close is called in order to force gwobex to
> resume the request and return any error related to it.
> ---
>  client/transfer.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/client/transfer.c b/client/transfer.c
> index 8ceb36f..e5fcfcc 100644
> --- a/client/transfer.c
> +++ b/client/transfer.c
> @@ -360,7 +360,7 @@ static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data)
>  {
>        struct transfer_data *transfer = user_data;
>        struct transfer_callback *callback = transfer->callback;
> -       gint written, err = 0;
> +       gint written = 0, err = 0;
>
>        if (transfer->buffer_len == 0) {
>                transfer->buffer_len = DEFAULT_BUFFER_SIZE;
> @@ -380,7 +380,12 @@ static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data)
>                transfer->filled += len;
>
>                if (transfer->filled == 0) {
> -                       gw_obex_xfer_flush(xfer, &err);
> +                       if (written > 0) {
> +                               gw_obex_xfer_flush(xfer, &err);
> +                               return;
> +                       }
> +
> +                       gw_obex_xfer_close(xfer, &err);
>                        goto done;
>                }

Actually I might simplify even more by not returning when flushing the
transfer, at that point we don't have anything else to write so
returning and waiting for gwobex to call it again is just a wait of
time, so please ignore this for now.

-- 
Luiz Augusto von Dentz
Computer Engineer

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

* Re: [PATCH] Fix not detecting errors on small files
  2010-09-30  8:09 Luiz Augusto von Dentz
@ 2010-09-30  8:20 ` Johan Hedberg
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2010-09-30  8:20 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Thu, Sep 30, 2010, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> Make use of gw_obex_xfer_close instead of gw_obex_xfer_flush since the
> former not only flushes the remaining data but also wait for the response
> catching errors that gw_obex_xfer_flush doesn't.
> ---
>  client/transfer.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks for the patch. It has been pushed upstream.

Johan

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

* [PATCH] Fix not detecting errors on small files
@ 2010-09-30  8:09 Luiz Augusto von Dentz
  2010-09-30  8:20 ` Johan Hedberg
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2010-09-30  8:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

Make use of gw_obex_xfer_close instead of gw_obex_xfer_flush since the
former not only flushes the remaining data but also wait for the response
catching errors that gw_obex_xfer_flush doesn't.
---
 client/transfer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index 8ceb36f..ea98b32 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -380,7 +380,7 @@ static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data)
 		transfer->filled += len;
 
 		if (transfer->filled == 0) {
-			gw_obex_xfer_flush(xfer, &err);
+			gw_obex_xfer_close(xfer, &err);
 			goto done;
 		}
 
-- 
1.7.1


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

end of thread, other threads:[~2010-09-30  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 14:27 [PATCH] Fix not detecting errors on small files Luiz Augusto von Dentz
2010-09-29 20:26 ` Luiz Augusto von Dentz
2010-09-30  8:09 Luiz Augusto von Dentz
2010-09-30  8:20 ` 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.