Increased the time slice given to reading from a connection

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_dev_next@1012 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java b/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java
index 5615525..238f2ee 100644
--- a/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java
+++ b/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java
@@ -29,6 +29,8 @@
 public class MultiplexedConnection implements ITCPConnectionEventListener {
     private static final Logger LOGGER = Logger.getLogger(MultiplexedConnection.class.getName());
 
+    private static final int MAX_CHUNKS_READ_PER_CYCLE = 4;
+
     private final MuxDemux muxDemux;
 
     private final IEventCounter pendingWriteEventsCounter;
@@ -273,8 +275,8 @@
 
     void driveReaderStateMachine() throws IOException, NetException {
         SocketChannel sc = tcpConnection.getSocketChannel();
-        boolean yield = false;
-        while (!yield) {
+        int chunksRead = 0;
+        while (chunksRead < MAX_CHUNKS_READ_PER_CYCLE) {
             if (readerState.readBuffer.remaining() > 0) {
                 int read = sc.read(readerState.readBuffer);
                 if (read < 0) {
@@ -334,7 +336,7 @@
                 }
             }
             if (readerState.pendingReadSize > 0) {
-                yield = true;
+                ++chunksRead;
                 int newPendingReadSize = readerState.ccb.read(sc, readerState.pendingReadSize);
                 muxDemux.getPerformanceCounters().addPayloadBytesRead(readerState.pendingReadSize - newPendingReadSize);
                 readerState.pendingReadSize = newPendingReadSize;