From 4507b177c35cfd918dba1cdc325fae3688fb7bd2 Mon Sep 17 00:00:00 2001 From: Anders Petersson Date: Wed, 27 Oct 2010 08:38:30 +0200 Subject: Bluetooth OBEX timeout problem. Long time to show notification of file transfer failed after canceling transfer via remote part. Device A is in contact with our device, B. When device A Cancel a transfer operation, it sends OBEX_OPCODE_DISCONNECT HeaderID and the length of package to B. B use the length of package to read remainder bytes from A. If the bytes B read do not meet the received length it will block and wait for remainder bytes from A. But when B compute the remainder bytes it forgets to subtract the three bytes it has already read through HeaderID and the length of the package. So the operation was blocked until the operation timeout. Change-Id: I0f8bf62d3119e081b5c01af9fc05fe586fd4fabc --- obex/javax/obex/ServerOperation.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'obex') diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java index 07a3a53482ea..d1476d271cfc 100644 --- a/obex/javax/obex/ServerOperation.java +++ b/obex/javax/obex/ServerOperation.java @@ -397,11 +397,13 @@ public final class ServerOperation implements Operation, BaseStream { && (headerID != ObexHelper.OBEX_OPCODE_GET_FINAL)) { if (length > 3) { - byte[] temp = new byte[length]; + byte[] temp = new byte[length - 3]; + // First three bytes already read, compensating for this bytesReceived = mInput.read(temp); - while (bytesReceived != length) { - bytesReceived += mInput.read(temp, bytesReceived, length - bytesReceived); + while (bytesReceived != temp.length) { + bytesReceived += mInput.read(temp, bytesReceived, + temp.length - bytesReceived); } } -- cgit v1.2.3