kopia lustrzana https://github.com/ge0rg/aprsdroid
fix TCP reconnection and error reporting
rodzic
c4df704997
commit
74572b62a7
|
@ -35,6 +35,7 @@ class TcpUploader(service : AprsService, prefs : SharedPreferences) extends Aprs
|
||||||
}
|
}
|
||||||
|
|
||||||
def stop() {
|
def stop() {
|
||||||
|
conn.running = false
|
||||||
conn.shutdown()
|
conn.shutdown()
|
||||||
conn.interrupt()
|
conn.interrupt()
|
||||||
conn.join()
|
conn.join()
|
||||||
|
@ -71,7 +72,7 @@ class TcpUploader(service : AprsService, prefs : SharedPreferences) extends Aprs
|
||||||
try {
|
try {
|
||||||
init_socket()
|
init_socket()
|
||||||
} catch {
|
} catch {
|
||||||
case e : Exception => service.postAbort(e.getMessage())
|
case e : Exception => service.postAbort(e.toString())
|
||||||
}
|
}
|
||||||
while (running) {
|
while (running) {
|
||||||
try {
|
try {
|
||||||
|
@ -84,11 +85,12 @@ class TcpUploader(service : AprsService, prefs : SharedPreferences) extends Aprs
|
||||||
}
|
}
|
||||||
if (running && (line == null || !socket.isConnected())) {
|
if (running && (line == null || !socket.isConnected())) {
|
||||||
Log.d(TAG, "reconnecting in 30s")
|
Log.d(TAG, "reconnecting in 30s")
|
||||||
|
shutdown()
|
||||||
Thread.sleep(30*1000)
|
Thread.sleep(30*1000)
|
||||||
init_socket()
|
init_socket()
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case e : Exception => Log.d(TAG, "Exception" + e)
|
case e : Exception => Log.d(TAG, "Exception " + e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(TAG, "TcpSocketThread.terminate()")
|
Log.d(TAG, "TcpSocketThread.terminate()")
|
||||||
|
@ -113,10 +115,10 @@ class TcpUploader(service : AprsService, prefs : SharedPreferences) extends Aprs
|
||||||
def shutdown() {
|
def shutdown() {
|
||||||
Log.d(TAG, "shutdown()")
|
Log.d(TAG, "shutdown()")
|
||||||
this.synchronized {
|
this.synchronized {
|
||||||
running = false
|
|
||||||
catchLog("shutdownInput", socket.shutdownInput)
|
catchLog("shutdownInput", socket.shutdownInput)
|
||||||
catchLog("shutdownOutput", socket.shutdownOutput)
|
catchLog("shutdownOutput", socket.shutdownOutput)
|
||||||
catchLog("socket.close", socket.close)
|
catchLog("socket.close", socket.close)
|
||||||
|
socket = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue