Mercurial > 510Connectbot
diff src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 417:4dcc071e1feb
monitor failure should not kill the TE
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 29 Oct 2014 12:12:48 -0700 |
parents | 057854c77217 |
children | 39533be5cbe9 |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Mon Oct 27 13:58:42 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Wed Oct 29 12:12:48 2014 -0700 @@ -181,25 +181,28 @@ monitor_socket = new Socket(serverAddr, MONITORPORT); } catch (Exception e) { + monitor_socket = null; Log.e(TAG, "exception connecting to monitor socket", e); tries = tries + 1; } } - Log.i(TAG, "connected to monitor socket, send init " + init); - monitor_in = monitor_socket.getInputStream(); - monitor_out = monitor_socket.getOutputStream(); - monitor_reader = new MyReader(monitor_in); - monitor_reader.start(); - String x = " " + init; - monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); - char [] c; + if (monitor_socket != null) { + Log.i(TAG, "connected to monitor socket, send init " + init); + monitor_in = monitor_socket.getInputStream(); + monitor_out = monitor_socket.getOutputStream(); + monitor_reader = new MyReader(monitor_in); + monitor_reader.start(); + String x = " " + init; + monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); + char [] c; - while (true) { - c = pending_commands.poll(); + while (true) { + c = pending_commands.poll(); - if (c == null) break; + if (c == null) break; - monitorWrite(c[1], c); + monitorWrite(c[1], c); + } } } catch (IOException e) { @@ -331,7 +334,7 @@ } else { c[1] = cmd; - pending_commands.put(c); + pending_commands.offer(c); } } catch (InterruptedException e) {