Skip to contentSkip to conversation

Fix suspend stream on opening if no data

PATCH New Dmitriy Paliy 3 participants 4 messages Oct 13, 2010 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

cover 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

#1 lore raw

PATCH 1/1 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(-)
src/obex.c +13 -1
index c7d0753..71bcba8 100644
@@ -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);
Signature · 1 line
1.7.0.4
#2 lore raw
Quoted 2 lines · Dmitriy Paliy

+ /* Try to write to stream and suspend the stream
immidiately

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

#3 lore raw
In reply to Dmitriy Paliy

Hi Dmitriy,

Quoted 5 lines · Dmitriy Paliy

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:

src/obex.c static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj) · line 820

Quoted 3 lines
src/obex.c +1 -0
 		OBEX_ObjectAddHeader (obex, obj, OBEX_HDR_BODY,
 				hd, 0, OBEX_FL_STREAM_START);
+		

Johan