2010-10-13 12:20:55

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH 0/1] Fix suspend stream on opening if no data

Hi,

This patch is to suspend obex stream on opening if there is no data
available yet to be sent. In such way unnecessary trafic is avoided
and IOP is improved with certain headsets. More specifically call
histories get requests from BH-902 are fixed.

Br,
Dmitriy



2010-10-13 12:30:44

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Fix suspend stream on opening if no data

Hi Dmitriy,

On Wed, Oct 13, 2010, Dmitriy Paliy wrote:
> Fix write to stream and suspend it immidiately if there is no data
> available.
> ---
> src/obex.c | 14 +++++++++++++-
> 1 files changed, 13 insertions(+), 1 deletions(-)

Looks good. The patch has been pushed upstream. Do pay attention to
whitespace issues in the future though. I got this when applying it:

Applying: Fix suspend stream on opening if no data
/home/jh/src/obexd/.git/rebase-apply/patch:18: trailing whitespace.
warning: 1 line applied after fixing whitespace errors.

This came from the empty line with two tabs after the AddHeader call:

> OBEX_ObjectAddHeader (obex, obj, OBEX_HDR_BODY,
> hd, 0, OBEX_FL_STREAM_START);
> +

Johan

2010-10-13 12:24:42

by Bastien Nocera

[permalink] [raw]
Subject: Re: [PATCH] Fix suspend stream on opening if no data

On Wed, 2010-10-13 at 15:20 +0300, Dmitriy Paliy wrote:
> + /* Try to write to stream and suspend the stream
> immidiately

Should be immediately (and in the log message as well)


2010-10-13 12:20:56

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH] Fix suspend stream on opening if no data

Fix write to stream and suspend it immidiately if there is no data
available.
---
src/obex.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index c7d0753..71bcba8 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -813,10 +813,22 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj)
os->obj = obj;
os->driver->set_io_watch(os->object, handle_async_io, os);
return;
- } else
+ } else {
/* Standard data stream */
OBEX_ObjectAddHeader (obex, obj, OBEX_HDR_BODY,
hd, 0, OBEX_FL_STREAM_START);
+
+ /* Try to write to stream and suspend the stream immidiately
+ * if no data available to send. */
+ err = obex_write_stream(os, obex, obj);
+ if (err == -EAGAIN) {
+ OBEX_SuspendRequest(obex, obj);
+ os->obj = obj;
+ os->driver->set_io_watch(os->object, handle_async_io,
+ os);
+ return;
+ }
+ }

done:
os_set_response(obj, err);
--
1.7.0.4