mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 14:39:53 +01:00
fixed a potential endless loop in SecureStreamSocketImpl::sendBytes()
and also removed unnecessary code
This commit is contained in:
parent
0434ee2b6b
commit
476a7e4f31
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// SecureStreamSocketImpl.cpp
|
// SecureStreamSocketImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.4/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp#4 $
|
// $Id: //poco/1.4/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp#6 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: SSLSockets
|
// Package: SSLSockets
|
||||||
@ -132,26 +132,7 @@ void SecureStreamSocketImpl::abort()
|
|||||||
|
|
||||||
int SecureStreamSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
int SecureStreamSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
||||||
{
|
{
|
||||||
const char* p = reinterpret_cast<const char*>(buffer);
|
return _impl.sendBytes(buffer, length, flags);
|
||||||
int remaining = length;
|
|
||||||
int sent = 0;
|
|
||||||
bool blocking = getBlocking();
|
|
||||||
while (remaining > 0)
|
|
||||||
{
|
|
||||||
int n = _impl.sendBytes(p, remaining, flags);
|
|
||||||
if (n < 0 && !blocking) return n;
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
p += n;
|
|
||||||
sent += n;
|
|
||||||
remaining -= n;
|
|
||||||
}
|
|
||||||
if (blocking && remaining > 0)
|
|
||||||
Poco::Thread::yield();
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return sent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user