porting 1.4.4 rev. 1968 (fixed SF# 3559665, etc.)

This commit is contained in:
Aleksandar Fabijanic 2012-08-23 03:15:19 +00:00
parent dbda035719
commit 2a6d58c7f2
4 changed files with 27 additions and 8 deletions

View File

@ -190,7 +190,6 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
_pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
n = static_cast<int>(_pIstr->gcount());
}
if (n == 0) return 0;
_zstr.next_in = (unsigned char*) _buffer;
_zstr.avail_in = n;
}

View File

@ -35,7 +35,9 @@
#include "CppUnit/TestSuite.h"
#include "Poco/InflatingStream.h"
#include "Poco/DeflatingStream.h"
#include "Poco/MemoryStream.h"
#include "Poco/StreamCopier.h"
#include "Poco/Buffer.h"
#include <sstream>
@ -113,6 +115,22 @@ void ZLibTest::testDeflate3()
}
void ZLibTest::testDeflate4()
{
Poco::Buffer<char> buffer(1024);
Poco::MemoryOutputStream ostr(buffer.begin(), static_cast<std::streamsize>(buffer.size()));
DeflatingOutputStream deflater(ostr, -10, Z_BEST_SPEED);
std::string data(36828, 'x');
deflater << data;
deflater.close();
Poco::MemoryInputStream istr(buffer.begin(), ostr.charsWritten());
InflatingInputStream inflater(istr, -10);
std::string data2;
inflater >> data2;
assert (data2 == data);
}
void ZLibTest::testGzip1()
{
std::stringstream buffer;
@ -196,6 +214,7 @@ CppUnit::Test* ZLibTest::suite()
CppUnit_addTest(pSuite, ZLibTest, testDeflate1);
CppUnit_addTest(pSuite, ZLibTest, testDeflate2);
CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
CppUnit_addTest(pSuite, ZLibTest, testDeflate4);
CppUnit_addTest(pSuite, ZLibTest, testGzip1);
CppUnit_addTest(pSuite, ZLibTest, testGzip2);
CppUnit_addTest(pSuite, ZLibTest, testGzip3);

View File

@ -49,6 +49,7 @@ public:
void testDeflate1();
void testDeflate2();
void testDeflate3();
void testDeflate4();
void testGzip1();
void testGzip2();
void testGzip3();

View File

@ -231,12 +231,12 @@ void SecureSocketImpl::listen(int backlog)
void SecureSocketImpl::shutdown()
{
if (_pSSL)
{
// Don't shut down the socket more than once.
int shutdownState = SSL_get_shutdown(_pSSL);
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
if (!shutdownSent)
{
{
// Don't shut down the socket more than once.
int shutdownState = SSL_get_shutdown(_pSSL);
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
if (!shutdownSent)
{
// A proper clean shutdown would require us to
// retry the shutdown if we get a zero return
// value, until SSL_shutdown() returns 1.
@ -254,7 +254,7 @@ void SecureSocketImpl::shutdown()
void SecureSocketImpl::close()
{
shutdown();
try { shutdown(); } catch (...) { }
_pSocket->close();
}