changeset 214:3e68cb17c0b6

socket runs dry sends flag to tnvt to call testChanged()
author Carl Byington <carl@five-ten-sg.com>
date Mon, 07 Jul 2014 15:09:22 -0700
parents d198328918fe
children 2d93d5063e3d
files src/org/tn5250j/framework/tn5250/DataStreamProducer.java src/org/tn5250j/framework/tn5250/tnvt.java
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/DataStreamProducer.java	Mon Jul 07 12:36:01 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/DataStreamProducer.java	Mon Jul 07 15:09:22 2014 -0700
@@ -146,6 +146,12 @@
         int i = 0;
 
         while (!done) {
+            try {
+                if (bin.available() == 0) dsq.put(new Integer(0));  // trigger buffer.testChanged()
+            }
+            catch (Exception ex) {
+                Log.w(TAG, "readIncoming error " + ex.getMessage());
+            }
             i = bin.read();
 
             // WVL - LDC : 16/07/2003 : TR.000345
@@ -218,6 +224,12 @@
 
         if (negotiate) {
             // get the negotiation option
+            try {
+                if (bin.available() == 0) dsq.put(new Integer(0));  // trigger buffer.testChanged()
+            }
+            catch (Exception ex) {
+                Log.w(TAG, "readIncoming error " + ex.getMessage());
+            }
             baosin.write(bin.read());
             vt.negotiate(rBytes);
             return null;
--- a/src/org/tn5250j/framework/tn5250/tnvt.java	Mon Jul 07 12:36:01 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/tnvt.java	Mon Jul 07 15:09:22 2014 -0700
@@ -982,11 +982,10 @@
 
         while (keepTrucking) {
             try {
-                Object e = dsq.poll(0L, TimeUnit.SECONDS);
-
-                if (e == null) {
+                Object e = dsq.take();
+
+                if ((e instanceof Integer) && ((Integer)e == 0)) {
                     buffer.testChanged();
-                    e = dsq.take();
                 };
 
                 bk.initialize((byte[])e);