From: "Zhao Forrest" <forrest.zhao@gmail.com>
To: "Johan Hedberg" <johan.hedberg@nokia.com>,
"Marcel Holtmann" <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: [patch] fix the bug of obex_object_resume(), obex_server() in openobex
Date: Tue, 23 Dec 2008 09:33:51 +0800 [thread overview]
Message-ID: <ac8af0be0812221733j262e8077re27476f18772079e@mail.gmail.com> (raw)
Hi,
When developing the PBAP server in obexd we found that
obex_object_resume() can't work as expected. After debugging openobex
we post this patch to fix the bug. We did the internal test with PBAP
server/client. The below patch fixes the bug in obex_object_resume()
and obex_server().
Thanks,
Forrest
diff --git a/lib/obex_object.c b/lib/obex_object.c
index 482e6a7..0af0108 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
@@ -908,24 +908,38 @@ int obex_object_suspend(obex_object_t *object)
int obex_object_resume(obex_t *self, obex_object_t *object)
{
+ int ret;
+
if (!object->suspend)
return 0;
object->suspend = 0;
- if (object->first_packet_sent && !object->continue_received)
+ if (object->first_packet_sent && !object->continue_received)
return 0;
- if (obex_object_send(self, object, TRUE, FALSE) < 0) {
- obex_deliver_event(self, OBEX_EV_LINKERR, object->opcode, 0, TRUE);
+ ret = obex_object_send(self, object, TRUE, FALSE);
+
+ if (ret < 0) {
+ obex_deliver_event(self, OBEX_EV_LINKERR, object->opcode &
~OBEX_FINAL, 0, TRUE);
return -1;
- }
+ } else if (ret == 0){
- obex_deliver_event(self, OBEX_EV_PROGRESS, object->opcode, 0, FALSE);
+ obex_deliver_event(self, OBEX_EV_PROGRESS, object->opcode &
~OBEX_FINAL, 0, FALSE);
+ object->first_packet_sent = 1;
+ object->continue_received = 0;
+ } else {
+ if (self->state & MODE_SRV) {
+ obex_deliver_event(self, OBEX_EV_REQDONE, object->opcode &
~OBEX_FINAL, 0, TRUE);
+ self->state = MODE_SRV | STATE_IDLE;
+ return 0;
+ }
+ }
- self->state = MODE_CLI | STATE_REC;
- object->first_packet_sent = 1;
- object->continue_received = 0;
+ if (self->state & MODE_SRV)
+ self->state = MODE_SRV | STATE_REC;
+ else
+ self->state = MODE_CLI | STATE_REC;
return 0;
}
diff --git a/lib/obex_server.c b/lib/obex_server.c
index f27c8ee..cf19529 100644
--- a/lib/obex_server.c
+++ b/lib/obex_server.c
@@ -159,7 +159,7 @@ int obex_server(obex_t *self, buf_t *msg, int final)
} else
obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE);
break; /* Stay in this state if not final */
- } else {
+ } else if (!self->object->first_packet_sent) {
DEBUG(4, "We got a request!\n");
/* More connect-magic woodoo stuff */
if (cmd == OBEX_CMD_CONNECT)
@@ -234,10 +234,17 @@ int obex_server(obex_t *self, buf_t *msg, int final)
* See Obex spec v1.2, chapter 3.2, page 21 and 22.
* See also example on chapter 7.3, page 47.
* So, force the final bit here. - Jean II */
+ self->object->continue_received = 1;
+
+ if (self->object->suspend)
+ break;
+
ret = obex_object_send(self, self->object, TRUE, TRUE);
if (ret == 0) {
/* Made some progress */
obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE);
+ self->object->first_packet_sent = 1;
+ self->object->continue_received = 0;
} else if (ret < 0) {
/* Error sending response */
obex_deliver_event(self, OBEX_EV_LINKERR, cmd, 0, TRUE);
next reply other threads:[~2008-12-23 1:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-23 1:33 Zhao Forrest [this message]
2008-12-24 1:23 ` [patch] fix the bug of obex_object_resume(), obex_server() in openobex Johan Hedberg
2008-12-24 3:13 ` [patch] obexd: if path == NULL, don't call dbus_connection_get_object_path_data Liu, Raymond
2008-12-24 3:41 ` Marcel Holtmann
2008-12-24 5:05 ` Liu, Raymond
2008-12-24 6:17 ` Marcel Holtmann
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=ac8af0be0812221733j262e8077re27476f18772079e@mail.gmail.com \
--to=forrest.zhao@gmail.com \
--cc=johan.hedberg@nokia.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.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