latest sources from main repository

This commit is contained in:
Guenter Obiltschnig 2007-06-13 15:14:53 +00:00
parent cfca5df1b6
commit f7b1357ec6
6 changed files with 43 additions and 11 deletions

View File

@ -1,7 +1,7 @@
//
// SocketDefs.h
//
// $Id: //poco/Main/Net/include/Poco/Net/SocketDefs.h#3 $
// $Id: //poco/Main/Net/include/Poco/Net/SocketDefs.h#4 $
//
// Library: Net
// Package: NetCore
@ -176,7 +176,7 @@
#endif
#if (POCO_OS == POCO_OS_HPUX)
#if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS)
#define POCO_BROKEN_TIMEOUTS 1
#endif

View File

@ -1,7 +1,7 @@
//
// SocketImpl.h
//
// $Id: //poco/Main/Net/include/Poco/Net/SocketImpl.h#2 $
// $Id: //poco/Main/Net/include/Poco/Net/SocketImpl.h#3 $
//
// Library: Net
// Package: Sockets
@ -407,6 +407,7 @@ private:
poco_socket_t _sockfd;
#if defined(POCO_BROKEN_TIMEOUTS)
Poco::Timespan _recvTimeout;
Poco::Timespan _sndTimeout;
#endif
friend class Socket;

View File

@ -1,7 +1,7 @@
//
// IPAddress.cpp
//
// $Id: //poco/Main/Net/src/IPAddress.cpp#16 $
// $Id: //poco/Main/Net/src/IPAddress.cpp#17 $
//
// Library: Net
// Package: NetCore
@ -82,6 +82,7 @@ public:
virtual bool isOrgLocalMC() const = 0;
virtual bool isGlobalMC() const = 0;
virtual void mask(const IPAddressImpl* pMask, const IPAddressImpl* pSet) = 0;
virtual IPAddressImpl* clone() const = 0;
protected:
IPAddressImpl()
@ -246,6 +247,11 @@ public:
_addr.s_addr &= static_cast<const IPv4AddressImpl*>(pMask)->_addr.s_addr;
_addr.s_addr |= static_cast<const IPv4AddressImpl*>(pSet)->_addr.s_addr & ~static_cast<const IPv4AddressImpl*>(pMask)->_addr.s_addr;
}
IPAddressImpl* clone() const
{
return new IPv4AddressImpl(&_addr);
}
private:
struct in_addr _addr;
@ -450,6 +456,11 @@ public:
throw Poco::NotImplementedException("mask() is only supported for IPv4 addresses");
}
IPAddressImpl* clone() const
{
return new IPv6AddressImpl(&_addr);
}
private:
struct in6_addr _addr;
};
@ -760,6 +771,9 @@ bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
void IPAddress::mask(const IPAddress& mask)
{
IPAddressImpl* pClone = _pImpl->clone();
_pImpl->release();
_pImpl = pClone;
IPAddress null;
_pImpl->mask(mask._pImpl, null._pImpl);
}
@ -767,6 +781,9 @@ void IPAddress::mask(const IPAddress& mask)
void IPAddress::mask(const IPAddress& mask, const IPAddress& set)
{
IPAddressImpl* pClone = _pImpl->clone();
_pImpl->release();
_pImpl = pClone;
_pImpl->mask(mask._pImpl, set._pImpl);
}

View File

@ -1,7 +1,7 @@
//
// MultipartReader.cpp
//
// $Id: //poco/Main/Net/src/MultipartReader.cpp#11 $
// $Id: //poco/Main/Net/src/MultipartReader.cpp#12 $
//
// Library: Net
// Package: Messages
@ -74,6 +74,7 @@ int MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length)
static const int eof = std::char_traits<char>::eof();
int n = 0;
int ch = _istr.get();
if (ch == eof) return -1;
*buffer++ = (char) ch; ++n;
if (ch == '\n' || ch == '\r' && _istr.peek() == '\n')
{

View File

@ -1,7 +1,7 @@
//
// Socket.cpp
//
// $Id: //poco/Main/Net/src/Socket.cpp#13 $
// $Id: //poco/Main/Net/src/Socket.cpp#14 $
//
// Library: Net
// Package: Sockets
@ -125,7 +125,7 @@ int Socket::select(SocketList& readList, SocketList& writeList, SocketList& exce
{
Poco::Timestamp end;
Poco::Timespan waited = end - start;
if (waited > remainingTime)
if (waited < remainingTime)
remainingTime -= waited;
else
remainingTime = 0;

View File

@ -1,7 +1,7 @@
//
// SocketImpl.cpp
//
// $Id: //poco/Main/Net/src/SocketImpl.cpp#22 $
// $Id: //poco/Main/Net/src/SocketImpl.cpp#23 $
//
// Library: Net
// Package: Sockets
@ -220,6 +220,14 @@ int SocketImpl::sendBytes(const void* buffer, int length, int flags)
{
poco_assert (_sockfd != POCO_INVALID_SOCKET);
#if defined(POCO_BROKEN_TIMEOUTS)
if (_sndTimeout.totalMicroseconds() != 0)
{
if (!poll(_sndTimeout, SELECT_WRITE))
throw TimeoutException();
}
#endif
int rc;
do
{
@ -359,7 +367,7 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
{
Poco::Timestamp end;
Poco::Timespan waited = end - start;
if (waited > remainingTime)
if (waited < remainingTime)
remainingTime -= waited;
else
remainingTime = 0;
@ -404,6 +412,8 @@ void SocketImpl::setSendTimeout(const Poco::Timespan& timeout)
#if defined(_WIN32)
int value = (int) timeout.totalMilliseconds();
setOption(SOL_SOCKET, SO_SNDTIMEO, value);
#elif defined(POCO_BROKEN_TIMEOUTS)
_sndTimeout = timeout;
#else
setOption(SOL_SOCKET, SO_SNDTIMEO, timeout);
#endif
@ -417,6 +427,8 @@ Poco::Timespan SocketImpl::getSendTimeout()
int value;
getOption(SOL_SOCKET, SO_SNDTIMEO, value);
result = Timespan::TimeDiff(value)*1000;
#elif defined(POCO_BROKEN_TIMEOUTS)
result = _sndTimeout;
#else
getOption(SOL_SOCKET, SO_SNDTIMEO, result);
#endif
@ -426,13 +438,14 @@ Poco::Timespan SocketImpl::getSendTimeout()
void SocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
{
#ifndef POCO_BROKEN_TIMEOUTS
#if defined(_WIN32)
int value = (int) timeout.totalMilliseconds();
setOption(SOL_SOCKET, SO_RCVTIMEO, value);
#else
setOption(SOL_SOCKET, SO_RCVTIMEO, timeout);
setOption(SOL_SOCKET, SO_RCVTIMEO, timeout);
#endif
#if defined(POCO_BROKEN_TIMEOUTS)
#else
_recvTimeout = timeout;
#endif
}