From 4ec68cecafc0e76fb302f2e0f407fe7cdb79ebb8 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Fri, 2 May 2008 16:41:14 +0000 Subject: [PATCH] fixed SF# 1956300: HTTPServerConnection hanging --- Net/include/Poco/Net/HTTPSession.h | 11 ++++++++++- Net/src/HTTPServerSession.cpp | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Net/include/Poco/Net/HTTPSession.h b/Net/include/Poco/Net/HTTPSession.h index 91ce51926..16d43359e 100644 --- a/Net/include/Poco/Net/HTTPSession.h +++ b/Net/include/Poco/Net/HTTPSession.h @@ -1,7 +1,7 @@ // // HTTPSession.h // -// $Id: //poco/svn/Net/include/Poco/Net/HTTPSession.h#2 $ +// $Id: //poco/Main/Net/include/Poco/Net/HTTPSession.h#5 $ // // Library: Net // Package: HTTP @@ -140,6 +140,9 @@ protected: int receive(char* buffer, int length); /// Reads up to length bytes. + + int buffered() const; + /// Returns the number of bytes in the buffer. StreamSocket& socket(); /// Returns a reference to the underlying socket. @@ -208,6 +211,12 @@ inline const Poco::Exception* HTTPSession::networkException() const } +inline int HTTPSession::buffered() const +{ + return static_cast(_pEnd - _pCurrent); +} + + } } // namespace Poco::Net diff --git a/Net/src/HTTPServerSession.cpp b/Net/src/HTTPServerSession.cpp index 21017bf5c..c72602b29 100644 --- a/Net/src/HTTPServerSession.cpp +++ b/Net/src/HTTPServerSession.cpp @@ -1,7 +1,7 @@ // // HTTPServerSession.cpp // -// $Id: //poco/svn/Net/src/HTTPServerSession.cpp#2 $ +// $Id: //poco/Main/Net/src/HTTPServerSession.cpp#9 $ // // Library: Net // Package: HTTPServer @@ -70,7 +70,7 @@ bool HTTPServerSession::hasMoreRequests() { if (_maxKeepAliveRequests > 0) --_maxKeepAliveRequests; - return socket().poll(_keepAliveTimeout, Socket::SELECT_READ); + return buffered() > 0 || socket().poll(_keepAliveTimeout, Socket::SELECT_READ); } else return false; }