mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 14:43:03 +01:00
Make zlib allocate memory from our pool
Add Z flag in protocol version for compressed connections Documentation
This commit is contained in:
parent
e487537ad2
commit
11c452251d
46
doc/README.wire.compression.html
Normal file
46
doc/README.wire.compression.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE></TITLE>
|
||||
<META NAME="GENERATOR" CONTENT="OpenOffice 4.1.1 (Unix)">
|
||||
<META NAME="AUTHOR" CONTENT="alex ">
|
||||
<META NAME="CREATED" CONTENT="20130531;10003100">
|
||||
<META NAME="CHANGEDBY" CONTENT="Alex Peshkoff">
|
||||
<META NAME="CHANGED" CONTENT="20141127;15401600">
|
||||
<STYLE TYPE="text/css">
|
||||
<!--
|
||||
@page { size: 8.5in 11in; margin: 0.79in }
|
||||
P { margin-bottom: 0.08in }
|
||||
-->
|
||||
</STYLE>
|
||||
</HEAD>
|
||||
<BODY LANG="en-US" DIR="LTR">
|
||||
<P STYLE="margin-top: 0.17in; margin-bottom: 0.2in; page-break-after: avoid">
|
||||
<FONT FACE="Albany, sans-serif"><FONT SIZE=4>Compressing data passed
|
||||
over the wire.</FONT></FONT></P>
|
||||
<P STYLE="margin-bottom: 0in"><BR>
|
||||
</P>
|
||||
<P>In most of cases compressing data passed over the wire is useless
|
||||
– one spends more time to compress a packet of data than to
|
||||
pass it over the typical LAN. But for WAN access data compression may
|
||||
be rather efficient way to enhance performance, specially when it can
|
||||
provide instead package size decrees packages' number decrees –
|
||||
that's the case for Firebird when it transfers a lot of data like big
|
||||
result set. zlib library (<A HREF="http://www.zlib.net/">http://www.zlib.net/</A>)
|
||||
is used by Firebird to compress data passed over the wire.</P>
|
||||
<P>By default wire compression is off, to turn it on you should set
|
||||
“WireCompression=true” in Firebird configuration on
|
||||
client. Compression setting is done by client to let only some
|
||||
clients that really need it use compression. Server gets compression
|
||||
setting from client when connection is established. Certainly only
|
||||
Firebird 3 (or higher) wire protocol supports compression. When
|
||||
compression is turned on Z flag is shown in client/server version
|
||||
info – for example: LI-T3.0.0.31451 Firebird 3.0 Beta 1/tcp
|
||||
(fbs)/P13:Z.</P>
|
||||
<P><BR><BR>
|
||||
</P>
|
||||
<P><BR><BR>
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
@ -1456,8 +1456,7 @@ void Attachment::getInfo(IStatus* status,
|
||||
item_length, items, 0, 0, buffer_length, temp_buffer);
|
||||
|
||||
string version;
|
||||
version.printf("%s/%s%s", FB_VERSION, port->port_version->str_data,
|
||||
port->port_crypt_complete ? ":C" : "");
|
||||
port->versionInfo(version);
|
||||
|
||||
MERGE_database_info(temp_buffer, buffer, buffer_length,
|
||||
DbImplementation::current.backwardCompatibleImplementation(), 3, 1,
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "../common/db_alias.h"
|
||||
#include "firebird/Interface.h"
|
||||
#include "../common/os/mod_loader.h"
|
||||
#include "../jrd/license.h"
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
Firebird::AtomicCounter rem_port::portCounter;
|
||||
@ -1360,6 +1361,23 @@ void SrvAuthBlock::putKey(Firebird::IStatus* status, Firebird::FbCryptKey* crypt
|
||||
}
|
||||
}
|
||||
|
||||
void rem_port::versionInfo(Firebird::string& version)
|
||||
{
|
||||
version.printf("%s/%s", FB_VERSION, port_version->str_data);
|
||||
#ifndef WIRE_COMPRESS_SUPPORT
|
||||
if (port_crypt_plugin)
|
||||
version += ":C";
|
||||
#else
|
||||
if (port_crypt_plugin || port_compressed)
|
||||
version += ':';
|
||||
if (port_crypt_plugin)
|
||||
version += 'C';
|
||||
if (port_compressed)
|
||||
version += 'Z';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIRE_COMPRESS_SUPPORT
|
||||
namespace {
|
||||
class ZLib
|
||||
@ -1402,6 +1420,16 @@ namespace {
|
||||
};
|
||||
|
||||
Firebird::InitInstance<ZLib> zlib;
|
||||
|
||||
void* allocFunc(void*, uInt items, uInt size)
|
||||
{
|
||||
return MemoryPool::globalAlloc(items * size);
|
||||
}
|
||||
|
||||
void freeFunc(void*, void* address)
|
||||
{
|
||||
MemoryPool::globalFree(address);
|
||||
}
|
||||
}
|
||||
#endif // WIRE_COMPRESS_SUPPORT
|
||||
|
||||
@ -1597,16 +1625,16 @@ void rem_port::initCompression()
|
||||
#ifdef WIRE_COMPRESS_SUPPORT
|
||||
if (port_protocol >= PROTOCOL_VERSION13 && !port_compressed)
|
||||
{
|
||||
port_send_stream.zalloc = Z_NULL;
|
||||
port_send_stream.zfree = Z_NULL;
|
||||
port_send_stream.zalloc = allocFunc;
|
||||
port_send_stream.zfree = freeFunc;
|
||||
port_send_stream.opaque = Z_NULL;
|
||||
int ret = zlib().deflateInit(&port_send_stream, Z_DEFAULT_COMPRESSION);
|
||||
if (ret != Z_OK)
|
||||
(Firebird::Arg::Gds(isc_random) << "compression stream init error").raise(); // add error code
|
||||
port_send_stream.next_out = NULL;
|
||||
|
||||
port_recv_stream.zalloc = Z_NULL;
|
||||
port_recv_stream.zfree = Z_NULL;
|
||||
port_recv_stream.zalloc = allocFunc;
|
||||
port_recv_stream.zfree = freeFunc;
|
||||
port_recv_stream.opaque = Z_NULL;
|
||||
port_recv_stream.avail_in = 0;
|
||||
port_recv_stream.next_in = Z_NULL;
|
||||
|
@ -989,6 +989,7 @@ public:
|
||||
void linkParent(rem_port* const parent);
|
||||
void unlinkParent();
|
||||
const Firebird::RefPtr<Config>& getPortConfig() const;
|
||||
void versionInfo(Firebird::string& version);
|
||||
|
||||
template <typename T>
|
||||
void getHandle(T*& blk, OBJCT id)
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "../remote/remote.h"
|
||||
#include "../common/file_params.h"
|
||||
#include "../common/ThreadStart.h"
|
||||
#include "../jrd/license.h"
|
||||
#include "../common/classes/timestamp.h"
|
||||
#include "../remote/merge_proto.h"
|
||||
#include "../remote/parse_proto.h"
|
||||
@ -3746,8 +3745,7 @@ void rem_port::info(P_OP op, P_INFO* stuff, PACKET* sendL)
|
||||
if (!(status_vector.getStatus() & Firebird::IStatus::FB_HAS_ERRORS))
|
||||
{
|
||||
string version;
|
||||
version.printf("%s/%s%s", FB_VERSION, this->port_version->str_data,
|
||||
this->port_crypt_complete ? ":C" : "");
|
||||
versionInfo(version);
|
||||
info_db_len = MERGE_database_info(temp_buffer, //temp
|
||||
buffer, buffer_length,
|
||||
DbImplementation::current.backwardCompatibleImplementation(), 4, 1,
|
||||
|
Loading…
Reference in New Issue
Block a user