From e1f398363812115611d20c0c803802c78ed65974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 25 Aug 2006 22:07:53 +0000 Subject: Fixed the connection manager to not suck with the new connection read api. --- src/connection.cpp | 3 +++ src/connectionmanager.cpp | 2 +- src/test/clistress/main.cpp | 23 +---------------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index 045ea17..c68c519 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -215,6 +215,8 @@ int Connection::readInput() } else { + if( nbytes == 0 ) + break; nTotalRead += nbytes; appendInput( buffer, nbytes ); /* Data read. */ @@ -258,6 +260,7 @@ bool Connection::readInput( int nSec, int nUSec, int *pnSecBack, int *pnUSecBack } else if( retval ) { + printf("retval=%d, nSocket=%d,%d, sec=%d, usec=%d\n", retval, nSocket, FD_ISSET( nSocket, &rfds ), tv.tv_sec, tv.tv_usec ); // None of them have data, but the connection is still active. if( readInput() == 0 ) { diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp index 88d7878..cffdf29 100644 --- a/src/connectionmanager.cpp +++ b/src/connectionmanager.cpp @@ -167,7 +167,7 @@ bool ConnectionManager::scanConnections( int nTimeout, bool bForceTimeout ) } /* Data arriving on an already-connected socket. */ - if( pCon->readInput() != true ) + if( pCon->readInput() == 0 ) { xLog.LineLog( MultiLog::LStatus, "Closing connection due to disconnect."); close( i ); diff --git a/src/test/clistress/main.cpp b/src/test/clistress/main.cpp index 3f5038b..0869945 100644 --- a/src/test/clistress/main.cpp +++ b/src/test/clistress/main.cpp @@ -1,26 +1,5 @@ #include "connection.h" -void _waitForLength( Connection &con, int len) -{ - int rlen = con.getInputAmnt(); - - if (rlen >= len) - return; - - int time_left = 5; - int mic_left = 0; - - while (rlen < len) - { - if (time_left == 0 && mic_left == 0) - { - throw "Socket Timeout"; - } - con.readInput(time_left, mic_left, &time_left, &mic_left); - rlen = con.getInputAmnt(); - } -} - int main() { Connection c; @@ -30,7 +9,7 @@ int main() c.appendOutput("d"); c.writeOutput(); - _waitForLength( c, 40 ); + c.waitForInput( 5, 40, 0 ); c.close(); -- cgit v1.2.3