Skip to content

Commit f7b1357

Browse files
committed
latest sources from main repository
1 parent cfca5df commit f7b1357

6 files changed

Lines changed: 43 additions & 11 deletions

File tree

Net/include/Poco/Net/SocketDefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// SocketDefs.h
33
//
4-
// $Id: //poco/Main/Net/include/Poco/Net/SocketDefs.h#3 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/SocketDefs.h#4 $
55
//
66
// Library: Net
77
// Package: NetCore
@@ -176,7 +176,7 @@
176176
#endif
177177

178178

179-
#if (POCO_OS == POCO_OS_HPUX)
179+
#if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS)
180180
#define POCO_BROKEN_TIMEOUTS 1
181181
#endif
182182

Net/include/Poco/Net/SocketImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// SocketImpl.h
33
//
4-
// $Id: //poco/Main/Net/include/Poco/Net/SocketImpl.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/SocketImpl.h#3 $
55
//
66
// Library: Net
77
// Package: Sockets
@@ -407,6 +407,7 @@ class Net_API SocketImpl: public Poco::RefCountedObject
407407
poco_socket_t _sockfd;
408408
#if defined(POCO_BROKEN_TIMEOUTS)
409409
Poco::Timespan _recvTimeout;
410+
Poco::Timespan _sndTimeout;
410411
#endif
411412

412413
friend class Socket;

Net/src/IPAddress.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// IPAddress.cpp
33
//
4-
// $Id: //poco/Main/Net/src/IPAddress.cpp#16 $
4+
// $Id: //poco/Main/Net/src/IPAddress.cpp#17 $
55
//
66
// Library: Net
77
// Package: NetCore
@@ -82,6 +82,7 @@ class IPAddressImpl: public RefCountedObject
8282
virtual bool isOrgLocalMC() const = 0;
8383
virtual bool isGlobalMC() const = 0;
8484
virtual void mask(const IPAddressImpl* pMask, const IPAddressImpl* pSet) = 0;
85+
virtual IPAddressImpl* clone() const = 0;
8586

8687
protected:
8788
IPAddressImpl()
@@ -246,6 +247,11 @@ class IPv4AddressImpl: public IPAddressImpl
246247
_addr.s_addr &= static_cast<const IPv4AddressImpl*>(pMask)->_addr.s_addr;
247248
_addr.s_addr |= static_cast<const IPv4AddressImpl*>(pSet)->_addr.s_addr & ~static_cast<const IPv4AddressImpl*>(pMask)->_addr.s_addr;
248249
}
250+
251+
IPAddressImpl* clone() const
252+
{
253+
return new IPv4AddressImpl(&_addr);
254+
}
249255

250256
private:
251257
struct in_addr _addr;
@@ -450,6 +456,11 @@ class IPv6AddressImpl: public IPAddressImpl
450456
throw Poco::NotImplementedException("mask() is only supported for IPv4 addresses");
451457
}
452458

459+
IPAddressImpl* clone() const
460+
{
461+
return new IPv6AddressImpl(&_addr);
462+
}
463+
453464
private:
454465
struct in6_addr _addr;
455466
};
@@ -760,13 +771,19 @@ bool IPAddress::tryParse(const std::string& addr, IPAddress& result)
760771

761772
void IPAddress::mask(const IPAddress& mask)
762773
{
774+
IPAddressImpl* pClone = _pImpl->clone();
775+
_pImpl->release();
776+
_pImpl = pClone;
763777
IPAddress null;
764778
_pImpl->mask(mask._pImpl, null._pImpl);
765779
}
766780

767781

768782
void IPAddress::mask(const IPAddress& mask, const IPAddress& set)
769783
{
784+
IPAddressImpl* pClone = _pImpl->clone();
785+
_pImpl->release();
786+
_pImpl = pClone;
770787
_pImpl->mask(mask._pImpl, set._pImpl);
771788
}
772789

Net/src/MultipartReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// MultipartReader.cpp
33
//
4-
// $Id: //poco/Main/Net/src/MultipartReader.cpp#11 $
4+
// $Id: //poco/Main/Net/src/MultipartReader.cpp#12 $
55
//
66
// Library: Net
77
// Package: Messages
@@ -74,6 +74,7 @@ int MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length)
7474
static const int eof = std::char_traits<char>::eof();
7575
int n = 0;
7676
int ch = _istr.get();
77+
if (ch == eof) return -1;
7778
*buffer++ = (char) ch; ++n;
7879
if (ch == '\n' || ch == '\r' && _istr.peek() == '\n')
7980
{

Net/src/Socket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Socket.cpp
33
//
4-
// $Id: //poco/Main/Net/src/Socket.cpp#13 $
4+
// $Id: //poco/Main/Net/src/Socket.cpp#14 $
55
//
66
// Library: Net
77
// Package: Sockets
@@ -125,7 +125,7 @@ int Socket::select(SocketList& readList, SocketList& writeList, SocketList& exce
125125
{
126126
Poco::Timestamp end;
127127
Poco::Timespan waited = end - start;
128-
if (waited > remainingTime)
128+
if (waited < remainingTime)
129129
remainingTime -= waited;
130130
else
131131
remainingTime = 0;

Net/src/SocketImpl.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// SocketImpl.cpp
33
//
4-
// $Id: //poco/Main/Net/src/SocketImpl.cpp#22 $
4+
// $Id: //poco/Main/Net/src/SocketImpl.cpp#23 $
55
//
66
// Library: Net
77
// Package: Sockets
@@ -220,6 +220,14 @@ int SocketImpl::sendBytes(const void* buffer, int length, int flags)
220220
{
221221
poco_assert (_sockfd != POCO_INVALID_SOCKET);
222222

223+
#if defined(POCO_BROKEN_TIMEOUTS)
224+
if (_sndTimeout.totalMicroseconds() != 0)
225+
{
226+
if (!poll(_sndTimeout, SELECT_WRITE))
227+
throw TimeoutException();
228+
}
229+
#endif
230+
223231
int rc;
224232
do
225233
{
@@ -359,7 +367,7 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
359367
{
360368
Poco::Timestamp end;
361369
Poco::Timespan waited = end - start;
362-
if (waited > remainingTime)
370+
if (waited < remainingTime)
363371
remainingTime -= waited;
364372
else
365373
remainingTime = 0;
@@ -404,6 +412,8 @@ void SocketImpl::setSendTimeout(const Poco::Timespan& timeout)
404412
#if defined(_WIN32)
405413
int value = (int) timeout.totalMilliseconds();
406414
setOption(SOL_SOCKET, SO_SNDTIMEO, value);
415+
#elif defined(POCO_BROKEN_TIMEOUTS)
416+
_sndTimeout = timeout;
407417
#else
408418
setOption(SOL_SOCKET, SO_SNDTIMEO, timeout);
409419
#endif
@@ -417,6 +427,8 @@ Poco::Timespan SocketImpl::getSendTimeout()
417427
int value;
418428
getOption(SOL_SOCKET, SO_SNDTIMEO, value);
419429
result = Timespan::TimeDiff(value)*1000;
430+
#elif defined(POCO_BROKEN_TIMEOUTS)
431+
result = _sndTimeout;
420432
#else
421433
getOption(SOL_SOCKET, SO_SNDTIMEO, result);
422434
#endif
@@ -426,13 +438,14 @@ Poco::Timespan SocketImpl::getSendTimeout()
426438

427439
void SocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
428440
{
441+
#ifndef POCO_BROKEN_TIMEOUTS
429442
#if defined(_WIN32)
430443
int value = (int) timeout.totalMilliseconds();
431444
setOption(SOL_SOCKET, SO_RCVTIMEO, value);
432445
#else
433-
setOption(SOL_SOCKET, SO_RCVTIMEO, timeout);
446+
setOption(SOL_SOCKET, SO_RCVTIMEO, timeout);
434447
#endif
435-
#if defined(POCO_BROKEN_TIMEOUTS)
448+
#else
436449
_recvTimeout = timeout;
437450
#endif
438451
}

0 commit comments

Comments
 (0)