linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH obexd 1/3] Fix not responding when driver_get_headers return 0
Date: Wed, 11 Jan 2012 15:22:01 +0200	[thread overview]
Message-ID: <1326288123-31807-1-git-send-email-luiz.dentz@gmail.com> (raw)

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

When calling driver_get_headers it may not be ready but after the backend
respond the result can still be 0 which indicades no headers need to
added and we can start sending the body.
---
 src/obex.c |   40 ++++++++++++++++++----------------------
 1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 6307eaa..eb91f4c 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -643,16 +643,26 @@ static gssize driver_get_headers(struct obex_session *os)
 		total += len;
 	}
 
-	if (total == 0) {
-		g_obex_packet_free(rsp);
-		return 0;
+	if (total != 0) {
+		g_obex_send(os->obex, rsp, NULL);
+		os->get_rsp = g_obex_add_request_function(os->obex,
+							G_OBEX_OP_GET,
+							cmd_get_rsp, os);
+		goto done;
 	}
 
-	g_obex_send(os->obex, rsp, NULL);
-
-	os->get_rsp = g_obex_add_request_function(os->obex, G_OBEX_OP_GET,
-							cmd_get_rsp, os);
+	g_obex_packet_free(rsp);
+	if (os->size != OBJECT_SIZE_UNKNOWN && os->size < UINT32_MAX)
+		g_obex_get_rsp(os->obex, send_data, transfer_complete,
+						os, NULL,
+						G_OBEX_HDR_LENGTH, os->size,
+						G_OBEX_HDR_INVALID);
+	else
+		g_obex_get_rsp(os->obex, send_data, transfer_complete,
+						os, NULL,
+						G_OBEX_HDR_INVALID);
 
+done:
 	os->headers_sent = TRUE;
 
 	print_event(-1, G_OBEX_RSP_CONTINUE);
@@ -887,22 +897,8 @@ int obex_get_stream_start(struct obex_session *os, const char *filename)
 		g_obex_suspend(os->obex);
 		os->driver->set_io_watch(os->object, handle_async_io, os);
 		return 0;
-	} else if (err < 0) {
+	} else if (err < 0)
 		return err;
-	} else if (err > 0)
-		return 0;
-
-	if (os->size != OBJECT_SIZE_UNKNOWN && os->size < UINT32_MAX)
-		g_obex_get_rsp(os->obex, send_data, transfer_complete,
-						os, NULL,
-						G_OBEX_HDR_LENGTH, os->size,
-						G_OBEX_HDR_INVALID);
-	else
-		g_obex_get_rsp(os->obex, send_data, transfer_complete,
-						os, NULL,
-						G_OBEX_HDR_INVALID);
-
-	print_event(G_OBEX_OP_GET, G_OBEX_RSP_SUCCESS);
 
 	return 0;
 }
-- 
1.7.7.5


             reply	other threads:[~2012-01-11 13:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 13:22 Luiz Augusto von Dentz [this message]
2012-01-11 13:22 ` [PATCH obexd 2/3] gobex: introduce g_obex_get_rsp_pkt Luiz Augusto von Dentz
2012-01-11 13:22 ` [PATCH obexd 3/3] Fix not responding SUCCESS code to GET in some conditions Luiz Augusto von Dentz
2012-01-11 13:55 ` [PATCH obexd 1/3] Fix not responding when driver_get_headers return 0 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=1326288123-31807-1-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@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;
as well as URLs for NNTP newsgroup(s).