remote.h (Firebird-3.0.2.32703-0.tar.bz2) | : | remote.h (Firebird-3.0.4.33054-0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
#include "../common/ThreadData.h" | #include "../common/ThreadData.h" | |||
#include "../common/ThreadStart.h" | #include "../common/ThreadStart.h" | |||
#include "../common/Auth.h" | #include "../common/Auth.h" | |||
#include "../common/classes/objects_array.h" | #include "../common/classes/objects_array.h" | |||
#include "../common/classes/fb_string.h" | #include "../common/classes/fb_string.h" | |||
#include "../common/classes/ClumpletWriter.h" | #include "../common/classes/ClumpletWriter.h" | |||
#include "../common/classes/RefMutex.h" | #include "../common/classes/RefMutex.h" | |||
#include "../common/StatusHolder.h" | #include "../common/StatusHolder.h" | |||
#include "../common/classes/RefCounted.h" | #include "../common/classes/RefCounted.h" | |||
#include "../common/classes/GetPlugins.h" | #include "../common/classes/GetPlugins.h" | |||
#include "../common/classes/RefMutex.h" | ||||
#include "firebird/Interface.h" | #include "firebird/Interface.h" | |||
#ifndef WIN_NT | #ifndef WIN_NT | |||
#include <signal.h> | #include <signal.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <sys/socket.h> | #include <sys/socket.h> | |||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | |||
#ifndef INVALID_SOCKET | #ifndef INVALID_SOCKET | |||
skipping to change at line 123 | skipping to change at line 124 | |||
namespace os_utils | namespace os_utils | |||
{ | { | |||
// force descriptor to have O_CLOEXEC set | // force descriptor to have O_CLOEXEC set | |||
SOCKET socket(int domain, int type, int protocol); | SOCKET socket(int domain, int type, int protocol); | |||
SOCKET accept(SOCKET sockfd, sockaddr *addr, socklen_t *addrlen); | SOCKET accept(SOCKET sockfd, sockaddr *addr, socklen_t *addrlen); | |||
} | } | |||
struct rem_port; | struct rem_port; | |||
typedef Firebird::AutoPtr<UCHAR, Firebird::ArrayDelete<UCHAR> > UCharArrayAutoPt r; | typedef Firebird::AutoPtr<UCHAR, Firebird::ArrayDelete> UCharArrayAutoPtr; | |||
typedef Firebird::RefPtr<Firebird::IAttachment> ServAttachment; | typedef Firebird::RefPtr<Firebird::IAttachment> ServAttachment; | |||
typedef Firebird::RefPtr<Firebird::IBlob> ServBlob; | typedef Firebird::RefPtr<Firebird::IBlob> ServBlob; | |||
typedef Firebird::RefPtr<Firebird::ITransaction> ServTransaction; | typedef Firebird::RefPtr<Firebird::ITransaction> ServTransaction; | |||
typedef Firebird::RefPtr<Firebird::IStatement> ServStatement; | typedef Firebird::RefPtr<Firebird::IStatement> ServStatement; | |||
typedef Firebird::RefPtr<Firebird::IResultSet> ServCursor; | typedef Firebird::RefPtr<Firebird::IResultSet> ServCursor; | |||
typedef Firebird::RefPtr<Firebird::IRequest> ServRequest; | typedef Firebird::RefPtr<Firebird::IRequest> ServRequest; | |||
typedef Firebird::RefPtr<Firebird::IEvents> ServEvents; | typedef Firebird::RefPtr<Firebird::IEvents> ServEvents; | |||
typedef Firebird::RefPtr<Firebird::IService> ServService; | typedef Firebird::RefPtr<Firebird::IService> ServService; | |||
skipping to change at line 255 | skipping to change at line 256 | |||
rbl_buffer(rbl_data.getBuffer(BLOB_LENGTH)), rbl_ptr(rbl_buffer), rbl_iface(NULL), | rbl_buffer(rbl_data.getBuffer(BLOB_LENGTH)), rbl_ptr(rbl_buffer), rbl_iface(NULL), | |||
rbl_offset(0), rbl_id(0), rbl_flags(0), | rbl_offset(0), rbl_id(0), rbl_flags(0), | |||
rbl_buffer_length(BLOB_LENGTH), rbl_length(0), rbl_fragment_lengt h(0), | rbl_buffer_length(BLOB_LENGTH), rbl_length(0), rbl_fragment_lengt h(0), | |||
rbl_source_interp(0), rbl_target_interp(0), rbl_self(NULL) | rbl_source_interp(0), rbl_target_interp(0), rbl_self(NULL) | |||
{ } | { } | |||
~Rbl() | ~Rbl() | |||
{ | { | |||
if (rbl_self && *rbl_self == this) | if (rbl_self && *rbl_self == this) | |||
*rbl_self = NULL; | *rbl_self = NULL; | |||
if (rbl_iface) | ||||
rbl_iface->release(); | ||||
} | } | |||
static ISC_STATUS badHandle() { return isc_bad_segstr_handle; } | static ISC_STATUS badHandle() { return isc_bad_segstr_handle; } | |||
}; | }; | |||
struct Rvnt : public Firebird::GlobalStorage, public TypedHandle<rem_type_rev> | struct Rvnt : public Firebird::GlobalStorage, public TypedHandle<rem_type_rev> | |||
{ | { | |||
Rvnt* rvnt_next; | Rvnt* rvnt_next; | |||
Rdb* rvnt_rdb; | Rdb* rvnt_rdb; | |||
Firebird::RefPtr<Firebird::IEventCallback> rvnt_callback; | Firebird::RefPtr<Firebird::IEventCallback> rvnt_callback; | |||
skipping to change at line 385 | skipping to change at line 389 | |||
rrq_rpt(getPool(), rpt), rrq_self(NULL) | rrq_rpt(getPool(), rpt), rrq_self(NULL) | |||
{ | { | |||
//memset(rrq_status_vector, 0, sizeof rrq_status_vector); | //memset(rrq_status_vector, 0, sizeof rrq_status_vector); | |||
rrq_rpt.grow(rpt); | rrq_rpt.grow(rpt); | |||
} | } | |||
~Rrq() | ~Rrq() | |||
{ | { | |||
if (rrq_self && *rrq_self == this) | if (rrq_self && *rrq_self == this) | |||
*rrq_self = NULL; | *rrq_self = NULL; | |||
if (rrq_iface) | ||||
rrq_iface->release(); | ||||
} | } | |||
Rrq* clone() const | Rrq* clone() const | |||
{ | { | |||
Rrq* rc = FB_NEW Rrq(rrq_rpt.getCount()); | Rrq* rc = FB_NEW Rrq(rrq_rpt.getCount()); | |||
*rc = *this; | *rc = *this; | |||
rc->rrq_self = NULL; | rc->rrq_self = NULL; | |||
return rc; | return rc; | |||
} | } | |||
skipping to change at line 497 | skipping to change at line 504 | |||
rsr_id(0), rsr_fmt_length(0), | rsr_id(0), rsr_fmt_length(0), | |||
rsr_rows_pending(0), rsr_msgs_waiting(0), rsr_reorder_level(0), r sr_batch_count(0), | rsr_rows_pending(0), rsr_msgs_waiting(0), rsr_reorder_level(0), r sr_batch_count(0), | |||
rsr_cursor_name(getPool()), rsr_delayed_format(false), rsr_self(N ULL) | rsr_cursor_name(getPool()), rsr_delayed_format(false), rsr_self(N ULL) | |||
{ } | { } | |||
~Rsr() | ~Rsr() | |||
{ | { | |||
if (rsr_self && *rsr_self == this) | if (rsr_self && *rsr_self == this) | |||
*rsr_self = NULL; | *rsr_self = NULL; | |||
if (rsr_cursor) | ||||
rsr_cursor->release(); | ||||
if (rsr_iface) | ||||
rsr_iface->release(); | ||||
delete rsr_status; | delete rsr_status; | |||
} | } | |||
void saveException(Firebird::IStatus* status, bool overwrite); | void saveException(Firebird::IStatus* status, bool overwrite); | |||
void saveException(const Firebird::Exception& ex, bool overwrite); | void saveException(const Firebird::Exception& ex, bool overwrite); | |||
void clearException(); | void clearException(); | |||
ISC_STATUS haveException(); | ISC_STATUS haveException(); | |||
void raiseException(); | void raiseException(); | |||
void releaseException(); | void releaseException(); | |||
skipping to change at line 688 | skipping to change at line 701 | |||
public Firebird::RefCntIface<Firebird::IClientBlockImpl<ClntAuthBlock, Fi rebird::CheckStatusWrapper> > | public Firebird::RefCntIface<Firebird::IClientBlockImpl<ClntAuthBlock, Fi rebird::CheckStatusWrapper> > | |||
{ | { | |||
private: | private: | |||
Firebird::PathName pluginList; // To be passed t o server | Firebird::PathName pluginList; // To be passed t o server | |||
Firebird::PathName serverPluginList; // Received from server | Firebird::PathName serverPluginList; // Received from server | |||
Firebird::string cliUserName, cliPassword; // Used by plugin, taken from DPB | Firebird::string cliUserName, cliPassword; // Used by plugin, taken from DPB | |||
Firebird::string cliOrigUserName; // Original user name, passed to server | Firebird::string cliOrigUserName; // Original user name, passed to server | |||
// These two are legacy encrypted password, trusted auth data and so on - what plugin needs | // These two are legacy encrypted password, trusted auth data and so on - what plugin needs | |||
Firebird::UCharBuffer dataForPlugin, dataFromPlugin; | Firebird::UCharBuffer dataForPlugin, dataFromPlugin; | |||
Firebird::HalfStaticArray<InternalCryptKey*, 1> cryptKeys; / / Wire crypt keys that came from plugin(s) last time | Firebird::HalfStaticArray<InternalCryptKey*, 1> cryptKeys; / / Wire crypt keys that came from plugin(s) last time | |||
Firebird::string dpbConfig; // Used to recrea | Firebird::string dpbConfig; // User's configu | |||
te config with new filename | retion parameters | |||
Firebird::PathName dpbPlugins; // User's plugin list | ||||
Firebird::RefPtr<const Config> clntConfig; // Used to get plugins li st and pass to port | Firebird::RefPtr<const Config> clntConfig; // Used to get plugins li st and pass to port | |||
unsigned nextKey; // First key to be analyzed | unsigned nextKey; // First key to be analyzed | |||
bool hasCryptKey; // DPB co ntains disk crypt key, may be passed only over encrypted wire | bool hasCryptKey; // DPB co ntains disk crypt key, may be passed only over encrypted wire | |||
public: | public: | |||
AuthClientPlugins plugins; | AuthClientPlugins plugins; | |||
bool authComplete; // Set as response from client that authentication accepted | bool authComplete; // Set as response from client that authentication accepted | |||
bool firstTime; // Invoke d first time after reset | bool firstTime; // Invoke d first time after reset | |||
skipping to change at line 846 | skipping to change at line 860 | |||
const USHORT PORT_dummy_pckt_set= 0x0010; // A dummy packet interval is set | const USHORT PORT_dummy_pckt_set= 0x0010; // A dummy packet interval is set | |||
const USHORT PORT_partial_data = 0x0020; // Physical packet doesn't contai n all API packet | const USHORT PORT_partial_data = 0x0020; // Physical packet doesn't contai n all API packet | |||
const USHORT PORT_lazy = 0x0040; // Deferred operations ar e allowed | const USHORT PORT_lazy = 0x0040; // Deferred operations ar e allowed | |||
const USHORT PORT_server = 0x0080; // Server (not client) po rt | const USHORT PORT_server = 0x0080; // Server (not client) po rt | |||
const USHORT PORT_detached = 0x0100; // op_detach, op_drop_dat abase or op_service_detach was processed | const USHORT PORT_detached = 0x0100; // op_detach, op_drop_dat abase or op_service_detach was processed | |||
const USHORT PORT_rdb_shutdown = 0x0200; // Database is shut down | const USHORT PORT_rdb_shutdown = 0x0200; // Database is shut down | |||
const USHORT PORT_connecting = 0x0400; // Aux connection waits for a cha nnel to be activated by client | const USHORT PORT_connecting = 0x0400; // Aux connection waits for a cha nnel to be activated by client | |||
const USHORT PORT_z_data = 0x0800; // Zlib incoming buffer h as data left after decompression | const USHORT PORT_z_data = 0x0800; // Zlib incoming buffer h as data left after decompression | |||
const USHORT PORT_compressed = 0x1000; // Compress outgoing stream (does not affect incoming) | const USHORT PORT_compressed = 0x1000; // Compress outgoing stream (does not affect incoming) | |||
// forward decl | ||||
class RemotePortGuard; | ||||
// Port itself | // Port itself | |||
typedef rem_port* (*t_port_connect)(rem_port*, PACKET*); | typedef rem_port* (*t_port_connect)(rem_port*, PACKET*); | |||
typedef Firebird::RefPtr<rem_port> RemPortPtr; | typedef Firebird::RefPtr<rem_port> RemPortPtr; | |||
struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted | struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted | |||
{ | { | |||
#ifdef DEV_BUILD | #ifdef DEV_BUILD | |||
static Firebird::AtomicCounter portCounter; | static Firebird::AtomicCounter portCounter; | |||
#endif | #endif | |||
// sync objects | // sync objects | |||
Firebird::RefPtr<Firebird::RefMutex> port_sync; | Firebird::RefPtr<Firebird::RefMutex> port_sync; | |||
Firebird::RefPtr<Firebird::RefMutex> port_que_sync; | Firebird::RefPtr<Firebird::RefMutex> port_que_sync; | |||
Firebird::RefPtr<Firebird::RefMutex> port_write_sync; | Firebird::RefPtr<Firebird::RefMutex> port_write_sync; | |||
Firebird::RefPtr<Firebird::RefMutex> port_cancel_sync; | ||||
// port function pointers (C "emulation" of virtual functions) | // port function pointers (C "emulation" of virtual functions) | |||
bool (*port_accept)(rem_port*, const p_cnct*); | bool (*port_accept)(rem_port*, const p_cnct*); | |||
void (*port_disconnect)(rem_port*); | void (*port_disconnect)(rem_port*); | |||
void (*port_force_close)(rem_port*); | void (*port_force_close)(rem_port*); | |||
rem_port* (*port_receive_packet)(rem_port*, PACKET*); | rem_port* (*port_receive_packet)(rem_port*, PACKET*); | |||
XDR_INT (*port_send_packet)(rem_port*, PACKET*); | XDR_INT (*port_send_packet)(rem_port*, PACKET*); | |||
XDR_INT (*port_send_partial)(rem_port*, PACKET*); | XDR_INT (*port_send_partial)(rem_port*, PACKET*); | |||
t_port_connect port_connect; // Establish secondary connection | t_port_connect port_connect; // Establish secondary connection | |||
rem_port* (*port_request)(rem_port*, PACKET*); // Reques t to establish secondary connection | rem_port* (*port_request)(rem_port*, PACKET*); // Reques t to establish secondary connection | |||
skipping to change at line 904 | skipping to change at line 922 | |||
USHORT port_buff_size; // port buffer size | USHORT port_buff_size; // port buffer size | |||
USHORT port_flags; // Misc flags | USHORT port_flags; // Misc flags | |||
SLONG port_connect_timeout; // Connection timeout val ue | SLONG port_connect_timeout; // Connection timeout val ue | |||
SLONG port_dummy_packet_interval; // keep alive dummy p acket interval | SLONG port_dummy_packet_interval; // keep alive dummy p acket interval | |||
SLONG port_dummy_timeout; // time remaining until k eepalive packet | SLONG port_dummy_timeout; // time remaining until k eepalive packet | |||
SOCKET port_handle; // handle for INET socket | SOCKET port_handle; // handle for INET socket | |||
SOCKET port_channel; // handle for connection (from by OS) | SOCKET port_channel; // handle for connection (from by OS) | |||
struct linger port_linger; // linger value as defined by SO_ LINGER | struct linger port_linger; // linger value as defined by SO_ LINGER | |||
Rdb* port_context; | Rdb* port_context; | |||
Thread::Handle port_events_thread; // handle of thread, handling inc oming events | Thread::Handle port_events_thread; // handle of thread, handling inc oming events | |||
void (*port_events_shutdown)(rem_port*); // hack - | ThreadId port_events_threadId; | |||
avoid changing API at beta stage | RemotePortGuard* port_thread_guard; // will close port_events_thread | |||
in safe way | ||||
#ifdef WIN_NT | #ifdef WIN_NT | |||
HANDLE port_pipe; // port pipe hand le | HANDLE port_pipe; // port pipe hand le | |||
HANDLE port_event; // event associat ed with a port | HANDLE port_event; // event associat ed with a port | |||
#endif | #endif | |||
XDR port_receive; | XDR port_receive; | |||
XDR port_send; | XDR port_send; | |||
#ifdef DEBUG_XDR_MEMORY | #ifdef DEBUG_XDR_MEMORY | |||
r e m _ v e c* port_packet_vector; // Vector of send/receive packets | r e m _ v e c* port_packet_vector; // Vector of send/receive packets | |||
#endif | #endif | |||
Firebird::Array<RemoteObject> port_objects; | Firebird::Array<RemoteObject> port_objects; | |||
skipping to change at line 964 | skipping to change at line 983 | |||
#ifdef WIRE_COMPRESS_SUPPORT | #ifdef WIRE_COMPRESS_SUPPORT | |||
z_stream port_send_stream, port_recv_stream; | z_stream port_send_stream, port_recv_stream; | |||
UCharArrayAutoPtr port_compressed; | UCharArrayAutoPtr port_compressed; | |||
#endif | #endif | |||
public: | public: | |||
rem_port(rem_port_t t, size_t rpt) : | rem_port(rem_port_t t, size_t rpt) : | |||
port_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | port_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | |||
port_que_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | port_que_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | |||
port_write_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | port_write_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | |||
port_cancel_sync(FB_NEW_POOL(getPool()) Firebird::RefMutex()), | ||||
port_accept(0), port_disconnect(0), port_force_close(0), port_rec eive_packet(0), port_send_packet(0), | port_accept(0), port_disconnect(0), port_force_close(0), port_rec eive_packet(0), port_send_packet(0), | |||
port_send_partial(0), port_connect(0), port_request(0), port_sele ct_multi(0), | port_send_partial(0), port_connect(0), port_request(0), port_sele ct_multi(0), | |||
port_type(t), port_state(PENDING), port_clients(0), port_next(0), | port_type(t), port_state(PENDING), port_clients(0), port_next(0), | |||
port_parent(0), port_async(0), port_async_receive(0), | port_parent(0), port_async(0), port_async_receive(0), | |||
port_server(0), port_server_flags(0), port_protocol(0), port_buff _size(rpt / 2), | port_server(0), port_server_flags(0), port_protocol(0), port_buff _size(rpt / 2), | |||
port_flags(0), port_connect_timeout(0), port_dummy_packet_interva l(0), | port_flags(0), port_connect_timeout(0), port_dummy_packet_interva l(0), | |||
port_dummy_timeout(0), port_handle(INVALID_SOCKET), port_channel( INVALID_SOCKET), port_context(0), | port_dummy_timeout(0), port_handle(INVALID_SOCKET), port_channel( INVALID_SOCKET), port_context(0), | |||
port_events_thread(0), port_events_shutdown(0), | port_events_thread(0), port_events_threadId(0), port_thread_guard (0), | |||
#ifdef WIN_NT | #ifdef WIN_NT | |||
port_pipe(INVALID_HANDLE_VALUE), port_event(INVALID_HANDLE_VALUE) , | port_pipe(INVALID_HANDLE_VALUE), port_event(INVALID_HANDLE_VALUE) , | |||
#endif | #endif | |||
#ifdef DEBUG_XDR_MEMORY | #ifdef DEBUG_XDR_MEMORY | |||
port_packet_vector(0), | port_packet_vector(0), | |||
#endif | #endif | |||
port_objects(getPool()), port_version(0), port_host(0), | port_objects(getPool()), port_version(0), port_host(0), | |||
port_connection(0), port_login(getPool()), | port_connection(0), port_login(getPool()), | |||
port_user_name(getPool()), port_peer_name(getPool()), | port_user_name(getPool()), port_peer_name(getPool()), | |||
port_protocol_id(getPool()), port_address(getPool()), | port_protocol_id(getPool()), port_address(getPool()), | |||
skipping to change at line 1193 | skipping to change at line 1213 | |||
Firebird::string getRemoteId() const; | Firebird::string getRemoteId() const; | |||
void auxAcceptError(PACKET* packet); | void auxAcceptError(PACKET* packet); | |||
void addServerKeys(CSTRING* str); | void addServerKeys(CSTRING* str); | |||
bool tryNewKey(InternalCryptKey* cryptKey); | bool tryNewKey(InternalCryptKey* cryptKey); | |||
void checkResponse(Firebird::IStatus* warning, PACKET* packet, bool check Keys = false); | void checkResponse(Firebird::IStatus* warning, PACKET* packet, bool check Keys = false); | |||
private: | private: | |||
bool tryKeyType(const KnownServerKey& srvKey, InternalCryptKey* cryptKey) ; | bool tryKeyType(const KnownServerKey& srvKey, InternalCryptKey* cryptKey) ; | |||
}; | }; | |||
// Port guard is needed to close events delivery thread in safe way | ||||
class RemotePortGuard | ||||
{ | ||||
private: | ||||
class WaitThread | ||||
{ | ||||
public: | ||||
WaitThread(rem_port* async) | ||||
: asyncPort(async), | ||||
waitFlag(false) | ||||
{ } | ||||
~WaitThread() | ||||
{ | ||||
if (waitFlag) | ||||
{ | ||||
Thread::waitForCompletion(waitHandle); | ||||
fb_assert(asyncPort); | ||||
if (asyncPort) | ||||
asyncPort->release(); | ||||
} | ||||
else if (asyncPort) | ||||
asyncPort->port_thread_guard = NULL; | ||||
} | ||||
rem_port* asyncPort; | ||||
Thread::Handle waitHandle; | ||||
bool waitFlag; | ||||
}; | ||||
public: | ||||
RemotePortGuard(rem_port* port, const char* f) | ||||
: wThr(port->port_async), | ||||
guard(*port->port_sync, f) | ||||
{ | ||||
if (wThr.asyncPort) | ||||
wThr.asyncPort->port_thread_guard = this; | ||||
} | ||||
void setWait(Thread::Handle& handle) | ||||
{ | ||||
wThr.waitHandle = handle; | ||||
wThr.waitFlag = true; | ||||
fb_assert(wThr.asyncPort); | ||||
wThr.asyncPort->port_thread_guard = NULL; | ||||
} | ||||
private: | ||||
WaitThread wThr; | ||||
Firebird::RefMutexGuard guard; | ||||
}; | ||||
// Queuing structure for Client batch fetches | // Queuing structure for Client batch fetches | |||
typedef void (*t_rmtque_fn)(rem_port*, rmtque*, USHORT); | typedef void (*t_rmtque_fn)(rem_port*, rmtque*, USHORT); | |||
struct rmtque : public Firebird::GlobalStorage | struct rmtque : public Firebird::GlobalStorage | |||
{ | { | |||
rmtque* rmtque_next; // Next entry in queue | rmtque* rmtque_next; // Next entry in queue | |||
void* rmtque_parm; // What request has respo nse in queue | void* rmtque_parm; // What request has respo nse in queue | |||
Rrq::rrq_repeat* rmtque_message; // What message is pending | Rrq::rrq_repeat* rmtque_message; // What message is pending | |||
Rdb* rmtque_rdb; // What database has pending msg | Rdb* rmtque_rdb; // What database has pending msg | |||
End of changes. 12 change blocks. | ||||
6 lines changed or deleted | 78 lines changed or added |