diff options
author | Kenny Root <kenny@the-b.org> | 2009-01-06 17:53:34 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2009-01-06 17:53:34 +0000 |
commit | f0608055043032691bb8bd4ec0186df8d721533d (patch) | |
tree | efcb52c7146ce523df6f7e4d9fb7432aee044df1 | |
parent | d16d18cb189448705640be430a8f6126b2c0c3fa (diff) | |
download | connectbot-f0608055043032691bb8bd4ec0186df8d721533d.tar.gz connectbot-f0608055043032691bb8bd4ec0186df8d721533d.tar.bz2 connectbot-f0608055043032691bb8bd4ec0186df8d721533d.zip |
Fix race condition when writing to local pre-connection buffer.
-rw-r--r-- | src/org/connectbot/service/TerminalBridge.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java index 14887f6..d198db4 100644 --- a/src/org/connectbot/service/TerminalBridge.java +++ b/src/org/connectbot/service/TerminalBridge.java @@ -494,11 +494,18 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal /** * Convenience method for writing a line into the underlying MUD buffer. + * Should never be called once the session is established. */ protected void outputLine(String line) { - localOutput.add(line + "\r\n"); + if (session != null) + Log.e(TAG, "Session established, cannot use outputLine!", new IOException("outputLine call traceback")); + + synchronized (localOutput) { + localOutput.add(line + "\r\n"); + + ((vt320) buffer).putString(line + "\r\n"); + } - ((vt320) buffer).putString(line + "\r\n"); redraw(); } @@ -979,8 +986,10 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal // redraw local output if we don't have a sesson to receive our resize request if (session == null) { ((vt320) buffer).reset(); - for (String line : localOutput) - ((vt320) buffer).putString(line); + synchronized (localOutput) { + for (String line : localOutput) + ((vt320) buffer).putString(line); + } } // force full redraw with new buffer size |