From 61dc8e837e1211a7462994e0950fb463e087f214 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 12 Dec 2018 22:21:02 -0800 Subject: [PATCH] cleanup --- .../java/org/eehouse/android/xw4/BTService.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java index 10d0048f6..f2f72ddf4 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java @@ -760,14 +760,7 @@ public class BTService extends XWService { } } - if ( null != m_serverSocket ) { - try { - m_serverSocket.close(); - } catch ( IOException ioe ) { - logIOE( ioe ); - } - m_serverSocket = null; - } + closeServerSocket(); } // run() private static class InPacket { @@ -840,6 +833,12 @@ public class BTService extends XWService { } public void stopListening() + { + closeServerSocket(); + interrupt(); + } + + private synchronized void closeServerSocket() { if ( null != m_serverSocket ) { try { @@ -849,7 +848,6 @@ public class BTService extends XWService { } m_serverSocket = null; } - interrupt(); } private boolean protoOK( byte proto, BTCmd cmd )