mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
fix concurrent access exception and too-slow sends
if we successfully send, we should reset the backoff so we try again quickly. Especially at a time when only one message is sent per connection.
This commit is contained in:
parent
a8241cc085
commit
9eef188ebe
1 changed files with 8 additions and 10 deletions
|
@ -1219,8 +1219,7 @@ public class BTService extends XWJIService {
|
||||||
Log.d( TAG, "%s.writeAndCheck() IN", this );
|
Log.d( TAG, "%s.writeAndCheck() IN", this );
|
||||||
Assert.assertNotNull( dos );
|
Assert.assertNotNull( dos );
|
||||||
|
|
||||||
List<MsgElem> localElems = null;
|
List<MsgElem> localElems = new ArrayList<>();
|
||||||
|
|
||||||
try ( DbgUtils.DeadlockWatch dw = new DbgUtils.DeadlockWatch( this ) ) {
|
try ( DbgUtils.DeadlockWatch dw = new DbgUtils.DeadlockWatch( this ) ) {
|
||||||
synchronized ( this ) {
|
synchronized ( this ) {
|
||||||
if ( 0 < mLength ) {
|
if ( 0 < mLength ) {
|
||||||
|
@ -1236,8 +1235,10 @@ public class BTService extends XWJIService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int ii = 0; ii < msgCount; ++ii ) {
|
for ( int ii = 0; ii < msgCount; ++ii ) {
|
||||||
byte[] elemData = mElems.get(ii).mData;
|
MsgElem elem = mElems.get(ii);
|
||||||
|
byte[] elemData = elem.mData;
|
||||||
tmpOP.dos.write( elemData, 0, elemData.length );
|
tmpOP.dos.write( elemData, 0, elemData.length );
|
||||||
|
localElems.add( elem );
|
||||||
}
|
}
|
||||||
byte[] data = tmpOP.bos.toByteArray();
|
byte[] data = tmpOP.bos.toByteArray();
|
||||||
|
|
||||||
|
@ -1252,17 +1253,12 @@ public class BTService extends XWJIService {
|
||||||
+ " %d-byte payload with sum %s (for %s)",
|
+ " %d-byte payload with sum %s (for %s)",
|
||||||
msgCount, data.length, Utils.getMD5SumFor( data ),
|
msgCount, data.length, Utils.getMD5SumFor( data ),
|
||||||
this );
|
this );
|
||||||
|
|
||||||
if ( IS_BATCH_PROTO() ) {
|
|
||||||
localElems = mElems;
|
|
||||||
} else {
|
|
||||||
localElems = mElems.subList(0, 1);
|
|
||||||
}
|
|
||||||
} catch ( IOException ioe ) {
|
} catch ( IOException ioe ) {
|
||||||
Log.e( TAG, "writeAndCheck(): ioe: %s", ioe.getMessage() );
|
Log.e( TAG, "writeAndCheck(): ioe: %s", ioe.getMessage() );
|
||||||
|
localElems = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // synchronized
|
||||||
}
|
}
|
||||||
|
|
||||||
int nDone = 0;
|
int nDone = 0;
|
||||||
|
@ -1438,6 +1434,8 @@ public class BTService extends XWJIService {
|
||||||
}
|
}
|
||||||
Log.d( TAG, "unappend(): after removing %d, have %d left for size %d",
|
Log.d( TAG, "unappend(): after removing %d, have %d left for size %d",
|
||||||
nToRemove, mElems.size(), mLength );
|
nToRemove, mElems.size(), mLength );
|
||||||
|
|
||||||
|
resetBackoff(); // we were successful sending, so should retry immediately
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue