linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH obexd 1/3] Fix not responding when driver_get_headers return 0
@ 2012-01-11 13:22 Luiz Augusto von Dentz
  2012-01-11 13:22 ` [PATCH obexd 2/3] gobex: introduce g_obex_get_rsp_pkt Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2012-01-11 13:22 UTC (permalink / raw)
  To: linux-bluetooth

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-11 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-11 13:22 [PATCH obexd 1/3] Fix not responding when driver_get_headers return 0 Luiz Augusto von Dentz
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

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).