changeset 399:aeb8c2e6d83a

add queue to buffer monitor socket writes to prevent blocking on socket output stream write
author Carl Byington <carl@five-ten-sg.com>
date Wed, 15 Oct 2014 18:03:27 -0700
parents 2a416391ffc3
children e856ecf87b10
files src/com/five_ten_sg/connectbot/service/TerminalMonitor.java
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Wed Oct 15 18:00:06 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Wed Oct 15 18:03:27 2014 -0700
@@ -95,17 +95,17 @@
                 }
             }
             catch (InterruptedException e) {
-                if (!is_closing) Log.e(TAG, "exception in monitorWrite()", e);
+                if (!is_closing) Log.e(TAG, "exception in MyWriter.run()", e);
             }
             catch (IOException e) {
-                Log.i(TAG, "exception in monitorWrite(), monitor died or closed the socket", e);
+                Log.i(TAG, "exception in MyWriter.run(), monitor died or closed the socket", e);
             }
 
             try {
                 monitor_out.close();
             }
-            catch (IOException ee) {
-                Log.e(TAG, "exception in monitorWrite() closing output stream", ee);
+            catch (IOException e) {
+                Log.e(TAG, "exception in MyWriter.run() closing output stream", e);
             }
             monitor_out = null;
         }
@@ -348,9 +348,14 @@
 
 
     public void monitorWrite(char cmd, char[] c) {
-        c[0] = (char)(c.length - 1);    // number of chars following
-        c[1] = cmd;
-        pending_commands.put(c);
+        try {
+            c[0] = (char)(c.length - 1);    // number of chars following
+            c[1] = cmd;
+            pending_commands.put(c);
+        }
+        catch (InterruptedException e) {
+            Log.e(TAG, "exception in monitorWrite()", e);
+        }
     };
 
     public void resetWatch() {