From e634250d62a500e85b0419b26d987c4c58e8a8c8 Mon Sep 17 00:00:00 2001 From: Dmitriy Paliy Date: Wed, 13 Oct 2010 15:20:56 +0300 Subject: [PATCH] obexd: Fix suspend stream on opening if no data Fix write to stream and suspend it immidiately if there is no data available. --- obexd/src/obex.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/obexd/src/obex.c b/obexd/src/obex.c index c7d075329..d1ac339b8 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -813,11 +813,23 @@ 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); } -- 2.47.3