ruffy: catch race-condition sending keep alive during disconnect.

This commit is contained in:
Johannes Mockenhaupt 2017-10-30 00:43:54 +01:00
parent 03443f3358
commit cccf6f175c
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -277,13 +277,21 @@ public class Ruffy extends Service {
}
while(rtModeRunning)
{
if(System.currentTimeMillis() > lastRtMessageSent +1000L) {
try {
if (System.currentTimeMillis() > lastRtMessageSent + 1000L) {
log("sending keep alive");
synchronized (rtSequenceSemaphore) {
rtSequence = Application.sendRTKeepAlive(rtSequence, btConn);
lastRtMessageSent = System.currentTimeMillis();
}
}
} catch (Exception e) {
if (rtModeRunning) {
fail("Error sending keep alive while rtModeRunning is still true");
} else {
fail("Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect");
}
}
try{
Thread.sleep(500);}catch(Exception e){/*ignore*/}
}