Linux bluetooth development
 help / color / mirror / Atom feed
From: Slawomir Bochenski <lkslawek@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Slawomir Bochenski <lkslawek@gmail.com>
Subject: [PATCH obexd 4/4] Simplify code for calling mime driver flush()
Date: Wed,  5 Oct 2011 16:32:40 +0200	[thread overview]
Message-ID: <1317825160-21429-4-git-send-email-lkslawek@gmail.com> (raw)
In-Reply-To: <1317825160-21429-1-git-send-email-lkslawek@gmail.com>

OBEX_EV_REQ is the last thing that we are going to receive on PUT and
this is always going to be delivered. As the service driver will start
receiving data at or before its .put(), we can simply call flush() after
that. This also makes flush() usable in PUTs without length header.
---
 src/obex.c |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 38c5ca6..2cabadb 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -625,11 +625,6 @@ write:
 		os->pending -= w;
 	}
 
-	/* Flush on EOS */
-	if (os->size != OBJECT_SIZE_UNKNOWN && os->size == os->offset &&
-							os->driver->flush)
-		return os->driver->flush(os->object) > 0 ? -EAGAIN : 0;
-
 	return 0;
 }
 
@@ -1140,19 +1135,16 @@ static void cmd_put(struct obex_session *os, obex_t *obex, obex_object_t *obj)
 		return;
 	}
 
-	/* Check if there is a body and it is not empty (size > 0), otherwise
-	   openobex won't notify us with OBEX_EV_STREAMAVAIL and it gonna reply
-	   right away */
-	if (os->size != 0)
-		return;
-
-	/* Flush immediatly since there is nothing to write so the driver
-	   has a chance to do something before we reply */
-	if (os->object && os->driver && os->driver->flush &&
-					os->driver->flush(os->object) > 0) {
-		OBEX_SuspendRequest(obex, obj);
-		os->obj = obj;
-		os->driver->set_io_watch(os->object, handle_async_io, os);
+	if (os->object && os->driver && os->driver->flush) {
+		err = os->driver->flush(os->object);
+		if (err == -EAGAIN) {
+			OBEX_SuspendRequest(obex, obj);
+			os->obj = obj;
+			os->driver->set_io_watch(os->object,
+							handle_async_io, os);
+		} else if (err < 0) {
+			os_set_response(obj, err);
+		}
 	}
 }
 
-- 
1.7.4.1


  parent reply	other threads:[~2011-10-05 14:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05 14:32 [PATCH obexd 1/4] Reverse order of calls in os_reset_session Slawomir Bochenski
2011-10-05 14:32 ` [PATCH obexd 2/4] Fix missing format in call to g_error_new Slawomir Bochenski
2011-10-05 14:32 ` [PATCH obexd 3/4] Write pending bytes only if mime object is open Slawomir Bochenski
2011-10-05 14:32 ` Slawomir Bochenski [this message]
2011-10-05 15:04   ` [PATCH obexd 4/4] Simplify code for calling mime driver flush() Slawomir Bochenski
2011-10-05 15:06   ` Luiz Augusto von Dentz
2011-10-05 15:17     ` Slawomir Bochenski
2011-10-05 15:20       ` Slawomir Bochenski
2011-10-05 15:38         ` Luiz Augusto von Dentz
2011-10-05 16:12           ` Slawomir Bochenski
2011-10-05 16:43             ` Luiz Augusto von Dentz
2011-10-05 17:28               ` Slawomir Bochenski
2011-10-06  7:44           ` Hendrik Sattler
2011-10-06  8:17             ` Luiz Augusto von Dentz
2011-10-06  8:21               ` Slawomir Bochenski
2011-10-06  9:17                 ` Luiz Augusto von Dentz
2011-10-06 12:07                   ` Slawomir Bochenski
2011-10-06 10:10               ` Hendrik Sattler
2011-10-06  8:23   ` Johan Hedberg
2011-10-05 14:40 ` [PATCH obexd 1/4] Reverse order of calls in os_reset_session Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317825160-21429-4-git-send-email-lkslawek@gmail.com \
    --to=lkslawek@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox