From: Alexander P. <ale...@us...> - 2008-03-24 15:28:43
|
Build Version : T2.5.0.19044 Firebird 2.5 Unstable (writeBuildNum.sh,v 1.19204 2008/03/24 15:28:41 alexpeshkof ) Update of /cvsroot/firebird/firebird2/src/remote In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv26272 Modified Files: inet.cpp inter_proto.h interface.cpp parse_proto.h parser.cpp protocol.cpp protocol.h remot_proto.h remote.cpp remote.h server.cpp xdr.cpp xdr.h Removed Files: allr.cpp allr_proto.h Log Message: Remote cleanup: 1. Avoid ALLR memory allocation routine (use new / delete). 2. Use common (TypedHandle) class to control consistency of handles. 3. Make ctors and dtors work - in most cases more work is needed to make them meaningful. Index: inet.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/inet.cpp,v retrieving revision 1.218 retrieving revision 1.219 diff -b -U3 -r1.218 -r1.219 --- inet.cpp 23 Mar 2008 18:21:49 -0000 1.218 +++ inet.cpp 24 Mar 2008 15:28:36 -0000 1.219 @@ -247,7 +247,6 @@ static int check_host(rem_port*, TEXT*, const TEXT*, const struct passwd*); static bool check_proxy(rem_port*, TEXT*, Firebird::string&); #endif // WIN_NT -static void cleanup_port(rem_port*); static void disconnect(rem_port*); static void exit_handler(void *); @@ -393,7 +392,7 @@ /* We need to establish a connection to a remote server. Allocate the necessary blocks and get ready to go. */ - RDB rdb = (RDB) ALLR_block(type_rdb, 0); + RDB rdb = new Rdb; PACKET* packet = &rdb->rdb_packet; /* Pick up some user identification information */ @@ -531,7 +530,7 @@ Firebird::string temp; temp.printf("%s/P%d", port->port_version->str_data, port->port_protocol & FB_PROTOCOL_MASK); - ALLR_free(port->port_version); + delete port->port_version; port->port_version = REMOTE_make_string(temp.c_str()); if (packet->p_acpt.p_acpt_architecture == ARCHITECTURE) { @@ -605,9 +604,7 @@ } if (host.hasData()) { - if (port->port_connection) { - ALLR_free(port->port_connection); - } + delete port->port_connection; port->port_connection = REMOTE_make_string(host.c_str()); } else { @@ -1207,11 +1204,7 @@ INET_initialized = true; } - rem_port* port = (rem_port*) ALLR_block(type_port, INET_remote_buffer * 2); - port->port_sync = FB_NEW(*getDefaultMemoryPool()) Firebird::RefMutex(); - port->port_sync->addRef(); - port->port_type = port_inet; - port->port_state = state_pending; + rem_port* port = new rem_port(rem_port::INET, INET_remote_buffer * 2); REMOTE_get_timeout_params(port, 0); TEXT buffer[BUFFER_SMALL]; @@ -1242,25 +1235,10 @@ 0, XDR_DECODE); -#ifdef REM_SERVER - port->port_queue = FB_NEW(*getDefaultMemoryPool()) - Firebird::ObjectsArray< Firebird::Array< char > >(*getDefaultMemoryPool()); - port->port_qoffset = 0; - port->port_que_sync = FB_NEW(*getDefaultMemoryPool()) Firebird::RefMutex(); - port->port_que_sync->addRef(); -#endif - if (parent && !(parent->port_server_flags & SRVR_thread_per_port)) { Firebird::MutexLockGuard guard(port_mutex); - - port->port_parent = parent; - port->port_next = parent->port_clients; - port->port_handle = parent->port_handle; - port->port_server = parent->port_server; - port->port_server_flags = parent->port_server_flags; - - parent->port_clients = parent->port_next = port; + port->linkParent(parent); } return port; @@ -1338,10 +1316,6 @@ address.sin_family = AF_INET; address.sin_port = ((struct sockaddr_in *)(response->p_resp_data.cstr_address))->sin_port; - int optval = 1; - setsockopt((SOCKET) port->port_handle, SOL_SOCKET, SO_KEEPALIVE, - (SCHAR*) &optval, sizeof(optval)); - status = connect(n, (struct sockaddr *) &address, sizeof(address)); const int inetErrNo = INET_ERRNO; @@ -1566,12 +1540,8 @@ && (!strcmp(source_user, user_name.c_str()) || !strcmp(source_user, "*"))) { - ALLR_free(port->port_user_name); - const SLONG length = strlen(target_user); - rem_str* string = (rem_str*) ALLR_block(type_str, (int) length); - port->port_user_name = string; - string->str_length = length; - strncpy(string->str_data, target_user, length); + delete port->port_user_name; + port->port_user_name = REMOTE_make_string(target_user); user_name = target_user; result = true; break; @@ -1639,7 +1609,7 @@ /* If this is a sub-port, unlink it from it's parent */ bool defer_cleanup = false; - port->port_state = state_disconnected; + port->port_state = rem_port::DISCONNECTED; rem_port* parent = port->port_parent; if (parent != NULL) { @@ -1664,7 +1634,7 @@ gds__unregister_cleanup(exit_handler, (void *) port); if (!defer_cleanup) { - cleanup_port(port); + delete port; } #ifdef DEBUG @@ -1685,60 +1655,6 @@ } -static void cleanup_port( rem_port* port) -{ -/************************************** - * - * c l e a n u p _ p o r t - * - ************************************** - * - * Functional description - * Walk through the port structure freeing - * allocated memory and then free the port. - * - **************************************/ - - if (port->port_version) - ALLR_free(port->port_version); - - if (port->port_connection) - ALLR_free(port->port_connection); - - if (port->port_user_name) - ALLR_free(port->port_user_name); - - if (port->port_host) - ALLR_free(port->port_host); - - if (port->port_object_vector) - ALLR_free(port->port_object_vector); - - if (port->port_protocol_str) - ALLR_free(port->port_protocol_str); - - if (port->port_address_str) - ALLR_free(port->port_address_str); - -#ifdef DEBUG_XDR_MEMORY - if (port->port_packet_vector) - ALLR_free(port->port_packet_vector); -#endif - -#ifdef REM_SERVER - delete port->port_queue; - port->port_que_sync->release(); -#endif - -#ifdef TRUSTED_AUTH - delete port->port_trusted_auth; -#endif - - port->port_sync->release(); - ALLR_free(port); - return; -} - static void exit_handler( void *arg) { /************************************** @@ -1765,9 +1681,9 @@ #endif for (rem_port* port = main_port; port; port = port->port_next) - if (port->port_state != state_broken) + if (port->port_state != rem_port::BROKEN) { - port->port_state = state_broken; + port->port_state = rem_port::BROKEN; shutdown((int) port->port_handle, 2); SOCLOSE((SOCKET) port->port_handle); } @@ -2101,7 +2017,7 @@ main_port->port_flags &= ~PORT_partial_data; if (packet->p_operation == op_exit) { - main_port->port_state = state_broken; + main_port->port_state = rem_port::BROKEN; } break; } @@ -2147,9 +2063,9 @@ { if (INET_shutting_down) { - if (main_port->port_state != state_broken) + if (main_port->port_state != rem_port::BROKEN) { - main_port->port_state = state_broken; + main_port->port_state = rem_port::BROKEN; SOCKET s = (SOCKET) main_port->port_handle; shutdown(s, 2); SOCLOSE(s); @@ -2324,7 +2240,7 @@ unhook_disconnected_ports(main_port); for (rem_port* port = main_port; port; port = port->port_next) { - if (port->port_state == state_pending) + if (port->port_state == rem_port::PENDING) { /* Adjust down the port's keepalive timer. */ @@ -2592,7 +2508,7 @@ * save the status vector strings in a permanent place. * **************************************/ - port->port_state = state_broken; + port->port_state = rem_port::BROKEN; ISC_STATUS* status_vector = NULL; if (port->port_context != NULL) { @@ -2987,7 +2903,7 @@ rem_port* port = INET_connect(node_name, packet, status_vector, FALSE, &dpb); if (!port) { - ALLR_free(rdb); + delete rdb; return NULL; } @@ -2999,7 +2915,7 @@ inet_error(port, "receive in try_connect", isc_net_connect_err, INET_ERRNO); disconnect(port); - ALLR_free(rdb); + delete rdb; return NULL; } @@ -3475,11 +3391,11 @@ Firebird::RefMutexEnsureUnlock portGuard(*port->port_sync); if (portGuard.tryEnter()) { - if (port->port_state == state_disconnected) { + if (port->port_state == rem_port::DISCONNECTED) { more = true; unhook_port(port, port->port_parent); portGuard.leave(); - cleanup_port(port); + delete port; break; } else { Index: inter_proto.h =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/inter_proto.h,v retrieving revision 1.16 retrieving revision 1.17 diff -b -U3 -r1.16 -r1.17 --- inter_proto.h 16 Jan 2008 07:55:26 -0000 1.16 +++ inter_proto.h 24 Mar 2008 15:28:36 -0000 1.17 @@ -28,78 +28,78 @@ extern "C" { #endif -ISC_STATUS REM_attach_database(ISC_STATUS*, SSHORT, const SCHAR*, struct rdb**, +ISC_STATUS REM_attach_database(ISC_STATUS*, SSHORT, const SCHAR*, struct Rdb**, SSHORT, const SCHAR*, const UCHAR*); -ISC_STATUS REM_attach_service(ISC_STATUS *, USHORT, TEXT *, struct rdb **, USHORT, SCHAR *); -ISC_STATUS REM_blob_info(ISC_STATUS*, struct rbl**, SSHORT, const SCHAR*, +ISC_STATUS REM_attach_service(ISC_STATUS *, USHORT, TEXT *, struct Rdb **, USHORT, SCHAR *); +ISC_STATUS REM_blob_info(ISC_STATUS*, struct Rbl**, SSHORT, const SCHAR*, SSHORT, SCHAR*); -ISC_STATUS REM_cancel_blob(ISC_STATUS *, struct rbl **); -ISC_STATUS REM_cancel_events(ISC_STATUS *, struct rdb **, SLONG *); -ISC_STATUS REM_close_blob(ISC_STATUS *, struct rbl **); -ISC_STATUS REM_commit_transaction(ISC_STATUS *, struct rtr **); -ISC_STATUS REM_commit_retaining(ISC_STATUS *, struct rtr **); -ISC_STATUS REM_compile_request(ISC_STATUS*, struct rdb**, struct rrq**, +ISC_STATUS REM_cancel_blob(ISC_STATUS *, struct Rbl **); +ISC_STATUS REM_cancel_events(ISC_STATUS *, struct Rdb **, SLONG *); +ISC_STATUS REM_close_blob(ISC_STATUS *, struct Rbl **); +ISC_STATUS REM_commit_transaction(ISC_STATUS *, struct Rtr **); +ISC_STATUS REM_commit_retaining(ISC_STATUS *, struct Rtr **); +ISC_STATUS REM_compile_request(ISC_STATUS*, struct Rdb**, struct Rrq**, USHORT, const UCHAR*); -ISC_STATUS REM_create_blob2(ISC_STATUS*, struct rdb**, struct rtr**, - struct rbl**, BID, USHORT, const UCHAR*); -ISC_STATUS REM_create_database(ISC_STATUS*, SSHORT, const SCHAR*, struct rdb**, +ISC_STATUS REM_create_blob2(ISC_STATUS*, struct Rdb**, struct Rtr**, + struct Rbl**, BID, USHORT, const UCHAR*); +ISC_STATUS REM_create_database(ISC_STATUS*, SSHORT, const SCHAR*, struct Rdb**, SSHORT, const SCHAR*, SSHORT, const UCHAR*); -ISC_STATUS REM_database_info(ISC_STATUS*, struct rdb**, SSHORT, const SCHAR*, +ISC_STATUS REM_database_info(ISC_STATUS*, struct Rdb**, SSHORT, const SCHAR*, SSHORT, SCHAR*); -ISC_STATUS REM_ddl(ISC_STATUS*, struct rdb**, struct rtr**, +ISC_STATUS REM_ddl(ISC_STATUS*, struct Rdb**, struct Rtr**, USHORT, const UCHAR*); -ISC_STATUS REM_detach_database(ISC_STATUS *, struct rdb **); -ISC_STATUS REM_detach_service(ISC_STATUS *, struct rdb **); -ISC_STATUS REM_drop_database(ISC_STATUS *, struct rdb **); -ISC_STATUS REM_allocate_statement(ISC_STATUS *, struct rdb **, struct rsr **); -ISC_STATUS REM_execute(ISC_STATUS *, struct rtr **, struct rsr **, USHORT, UCHAR *, USHORT, USHORT, UCHAR *); -ISC_STATUS REM_execute2(ISC_STATUS *, struct rtr **, struct rsr **, USHORT, UCHAR *, USHORT, USHORT, UCHAR *, USHORT, UCHAR *, USHORT, USHORT, UCHAR *); -ISC_STATUS REM_execute_immediate(ISC_STATUS*, struct rdb**, struct rtr**, +ISC_STATUS REM_detach_database(ISC_STATUS *, struct Rdb **); +ISC_STATUS REM_detach_service(ISC_STATUS *, struct Rdb **); +ISC_STATUS REM_drop_database(ISC_STATUS *, struct Rdb **); +ISC_STATUS REM_allocate_statement(ISC_STATUS *, struct Rdb **, struct Rsr **); +ISC_STATUS REM_execute(ISC_STATUS *, struct Rtr **, struct Rsr **, USHORT, UCHAR *, USHORT, USHORT, UCHAR *); +ISC_STATUS REM_execute2(ISC_STATUS *, struct Rtr **, struct Rsr **, USHORT, UCHAR *, USHORT, USHORT, UCHAR *, USHORT, UCHAR *, USHORT, USHORT, UCHAR *); +ISC_STATUS REM_execute_immediate(ISC_STATUS*, struct Rdb**, struct Rtr**, USHORT, const TEXT*, USHORT, USHORT, const UCHAR*, USHORT, USHORT, UCHAR*); -ISC_STATUS REM_execute_immediate2(ISC_STATUS*, struct rdb**, struct rtr**, +ISC_STATUS REM_execute_immediate2(ISC_STATUS*, struct Rdb**, struct Rtr**, USHORT, const TEXT*, USHORT, USHORT, const UCHAR*, USHORT, USHORT, UCHAR*, USHORT, UCHAR*, USHORT, USHORT, UCHAR*); -ISC_STATUS REM_fetch(ISC_STATUS*, struct rsr**, USHORT, const UCHAR*, USHORT, +ISC_STATUS REM_fetch(ISC_STATUS*, struct Rsr**, USHORT, const UCHAR*, USHORT, USHORT, UCHAR*); -ISC_STATUS REM_free_statement(ISC_STATUS *, struct rsr **, USHORT); -ISC_STATUS REM_insert(ISC_STATUS *, struct rsr **, USHORT, UCHAR *, USHORT, USHORT, UCHAR *); -ISC_STATUS REM_prepare(ISC_STATUS *, struct rtr **, struct rsr **, USHORT, TEXT *, USHORT, USHORT, SCHAR *, USHORT, SCHAR *); -ISC_STATUS REM_set_cursor_name(ISC_STATUS*, struct rsr**, const TEXT*, USHORT); -ISC_STATUS REM_sql_info(ISC_STATUS*, struct rsr**, SSHORT, const SCHAR*, +ISC_STATUS REM_free_statement(ISC_STATUS *, struct Rsr **, USHORT); +ISC_STATUS REM_insert(ISC_STATUS *, struct Rsr **, USHORT, UCHAR *, USHORT, USHORT, UCHAR *); +ISC_STATUS REM_prepare(ISC_STATUS *, struct Rtr **, struct Rsr **, USHORT, TEXT *, USHORT, USHORT, SCHAR *, USHORT, SCHAR *); +ISC_STATUS REM_set_cursor_name(ISC_STATUS*, struct Rsr**, const TEXT*, USHORT); +ISC_STATUS REM_sql_info(ISC_STATUS*, struct Rsr**, SSHORT, const SCHAR*, SSHORT, SCHAR*); -ISC_STATUS REM_get_segment(ISC_STATUS *, struct rbl **, USHORT *, USHORT, UCHAR *); -ISC_STATUS REM_get_slice(ISC_STATUS*, struct rdb**, struct rtr**, BID, USHORT, +ISC_STATUS REM_get_segment(ISC_STATUS *, struct Rbl **, USHORT *, USHORT, UCHAR *); +ISC_STATUS REM_get_slice(ISC_STATUS*, struct Rdb**, struct Rtr**, BID, USHORT, const UCHAR*, USHORT, const UCHAR*, SLONG, UCHAR*, SLONG*); -ISC_STATUS REM_open_blob2(ISC_STATUS*, struct rdb**, struct rtr**, - struct rbl**, BID, USHORT, const UCHAR*); -ISC_STATUS REM_prepare_transaction(ISC_STATUS *, struct rtr **, USHORT, const UCHAR*); -ISC_STATUS REM_put_segment(ISC_STATUS*, struct rbl**, USHORT, const UCHAR*); -ISC_STATUS REM_put_slice(ISC_STATUS*, struct rdb**, struct rtr**, BID, USHORT, +ISC_STATUS REM_open_blob2(ISC_STATUS*, struct Rdb**, struct Rtr**, + struct Rbl**, BID, USHORT, const UCHAR*); +ISC_STATUS REM_prepare_transaction(ISC_STATUS *, struct Rtr **, USHORT, const UCHAR*); +ISC_STATUS REM_put_segment(ISC_STATUS*, struct Rbl**, USHORT, const UCHAR*); +ISC_STATUS REM_put_slice(ISC_STATUS*, struct Rdb**, struct Rtr**, BID, USHORT, const UCHAR*, USHORT, const UCHAR*, SLONG, UCHAR*); -ISC_STATUS REM_que_events(ISC_STATUS*, struct rdb**, SLONG*, SSHORT, +ISC_STATUS REM_que_events(ISC_STATUS*, struct Rdb**, SLONG*, SSHORT, const UCHAR*, FPTR_EVENT_CALLBACK, void*); -ISC_STATUS REM_query_service(ISC_STATUS *, struct rdb **, USHORT, SCHAR *, USHORT, SCHAR *, USHORT, SCHAR *); +ISC_STATUS REM_query_service(ISC_STATUS *, struct Rdb **, USHORT, SCHAR *, USHORT, SCHAR *, USHORT, SCHAR *); #ifdef SCROLLABLE_CURSORS -ISC_STATUS REM_receive(ISC_STATUS*, struct rrq**, USHORT, USHORT, UCHAR*, SSHORT, USHORT, ULONG); +ISC_STATUS REM_receive(ISC_STATUS*, struct Rrq**, USHORT, USHORT, UCHAR*, SSHORT, USHORT, ULONG); #else -ISC_STATUS REM_receive(ISC_STATUS *, struct rrq **, USHORT, USHORT, UCHAR *, SSHORT); +ISC_STATUS REM_receive(ISC_STATUS *, struct Rrq **, USHORT, USHORT, UCHAR *, SSHORT); #endif -ISC_STATUS REM_reconnect_transaction(ISC_STATUS*, struct rdb**, struct rtr**, +ISC_STATUS REM_reconnect_transaction(ISC_STATUS*, struct Rdb**, struct Rtr**, USHORT, const UCHAR*); -ISC_STATUS REM_release_request(ISC_STATUS *, struct rrq **); -ISC_STATUS REM_request_info(ISC_STATUS*, struct rrq**, SSHORT, SSHORT, +ISC_STATUS REM_release_request(ISC_STATUS *, struct Rrq **); +ISC_STATUS REM_request_info(ISC_STATUS*, struct Rrq**, SSHORT, SSHORT, const UCHAR*, SSHORT, UCHAR*); -ISC_STATUS REM_rollback_transaction(ISC_STATUS *, struct rtr **); -ISC_STATUS REM_seek_blob(ISC_STATUS *, struct rbl **, SSHORT, SLONG, SLONG *); -ISC_STATUS REM_send(ISC_STATUS *, struct rrq **, USHORT, USHORT, UCHAR *, SSHORT); -ISC_STATUS REM_start_and_send(ISC_STATUS *, struct rrq **, struct rtr **, USHORT, USHORT, UCHAR *, SSHORT); -ISC_STATUS REM_start_request(ISC_STATUS *, struct rrq **, struct rtr **, USHORT); -ISC_STATUS REM_start_transaction(ISC_STATUS *, struct rtr **, SSHORT, struct rdb **, SSHORT, UCHAR *); -ISC_STATUS REM_transact_request(ISC_STATUS*, struct rdb**, struct rtr**, +ISC_STATUS REM_rollback_transaction(ISC_STATUS *, struct Rtr **); +ISC_STATUS REM_seek_blob(ISC_STATUS *, struct Rbl **, SSHORT, SLONG, SLONG *); +ISC_STATUS REM_send(ISC_STATUS *, struct Rrq **, USHORT, USHORT, UCHAR *, SSHORT); +ISC_STATUS REM_start_and_send(ISC_STATUS *, struct Rrq **, struct Rtr **, USHORT, USHORT, UCHAR *, SSHORT); +ISC_STATUS REM_start_request(ISC_STATUS *, struct Rrq **, struct Rtr **, USHORT); +ISC_STATUS REM_start_transaction(ISC_STATUS *, struct Rtr **, SSHORT, struct Rdb **, SSHORT, UCHAR *); +ISC_STATUS REM_transact_request(ISC_STATUS*, struct Rdb**, struct Rtr**, USHORT, const UCHAR*, USHORT, UCHAR*, USHORT, UCHAR*); -ISC_STATUS REM_transaction_info(ISC_STATUS*, struct rtr**, SSHORT, +ISC_STATUS REM_transaction_info(ISC_STATUS*, struct Rtr**, SSHORT, const UCHAR*, SSHORT, UCHAR*); -ISC_STATUS REM_unwind_request(ISC_STATUS *, struct rrq **, USHORT); +ISC_STATUS REM_unwind_request(ISC_STATUS *, struct Rrq **, USHORT); ISC_STATUS REM_rollback_retaining(ISC_STATUS *, RTR *); ISC_STATUS REM_service_attach(ISC_STATUS*, USHORT, const TEXT*, RDB*, USHORT, Index: interface.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/interface.cpp,v retrieving revision 1.172 retrieving revision 1.173 diff -b -U3 -r1.172 -r1.173 --- interface.cpp 14 Mar 2008 10:43:36 -0000 1.172 +++ interface.cpp 24 Mar 2008 15:28:36 -0000 1.173 @@ -137,11 +137,11 @@ static bool clear_stmt_que(rem_port*, ISC_STATUS*, RSR); static void disconnect(rem_port*); #ifdef SCROLLABLE_CURSORS -static REM_MSG dump_cache(rem_port*, ISC_STATUS *, rrq::rrq_repeat *); +static REM_MSG dump_cache(rem_port*, ISC_STATUS *, Rrq::rrq_repeat *); #endif static void enqueue_receive(rem_port*, t_rmtque_fn, - RDB, void*, rrq::rrq_repeat*); + RDB, void*, Rrq::rrq_repeat*); static void dequeue_receive(rem_port*); static THREAD_ENTRY_DECLARE event_thread(THREAD_ENTRY_PARAM); static ISC_STATUS fetch_blob(ISC_STATUS*, RSR, USHORT, const UCHAR*, USHORT, @@ -159,7 +159,7 @@ static RTR make_transaction(RDB, USHORT); static ISC_STATUS mov_dsql_message(ISC_STATUS*, const UCHAR*, const rem_fmt*, UCHAR*, const rem_fmt*); static void move_error(ISC_STATUS, ...); -static void receive_after_start(rrq*, USHORT); +static void receive_after_start(Rrq*, USHORT); static bool receive_packet(rem_port*, PACKET *, ISC_STATUS *); static bool receive_packet_noqueue(rem_port*, PACKET *, ISC_STATUS *); static bool receive_queued_packet(rem_port*, ISC_STATUS *, USHORT); @@ -167,13 +167,13 @@ static void release_blob(RBL); static void release_event(RVNT); static bool release_object(RDB, P_OP, USHORT); -static void release_request(rrq*); +static void release_request(Rrq*); static void release_statement(RSR *); static void release_sql_request(RSR); static void release_transaction(RTR); static ISC_STATUS return_success(RDB); #ifdef SCROLLABLE_CURSORS -static REM_MSG scroll_cache(ISC_STATUS *, rrq*, rem_port*, rrq::rrq_repeat *, +static REM_MSG scroll_cache(ISC_STATUS *, Rrq*, rem_port*, Rrq::rrq_repeat *, USHORT *, ULONG *); #endif static ISC_STATUS send_and_receive(RDB, PACKET *, ISC_STATUS *); @@ -188,12 +188,12 @@ static ULONG remote_event_id = 0; -#define CHECK_HANDLE(blk, type, error) if (!blk || ((BLK) blk)->blk_type != (UCHAR) type) \ +#define CHECK_HANDLE(blk, type, error) if (!blk->checkHandle()) \ return handle_error (user_status, (ISC_STATUS) error) #define NULL_CHECK(ptr, code) if (*ptr) return handle_error (user_status, (ISC_STATUS) code) -#define SET_OBJECT(rdb, object, id) REMOTE_set_object (rdb->rdb_port, (struct blk *) object, id) +#define SET_OBJECT(rdb, object, id) rdb->rdb_port->setHandle(object, id) inline bool defer_packet(rem_port* port, PACKET* packet, ISC_STATUS* status, bool sent = false) { @@ -513,7 +513,7 @@ try { if (!(port->port_flags & PORT_rpc) && - (blob->rbl_flags & RBL_create) && blob->rbl_ptr != blob->rbl_buffer) + (blob->rbl_flags & Rbl::CREATE) && blob->rbl_ptr != blob->rbl_buffer) { if (send_blob(user_status, blob, 0, NULL)) { return user_status[1]; @@ -621,7 +621,7 @@ ISC_STATUS GDS_COMPILE(ISC_STATUS* user_status, RDB* db_handle, - rrq** req_handle, USHORT blr_length, const UCHAR* blr) + Rrq** req_handle, USHORT blr_length, const UCHAR* blr) { /************************************** * @@ -667,7 +667,7 @@ send_and_receive(rdb, packet, user_status); if (new_blr != blr) { - ALLR_free((void*) new_blr); + delete new_blr; } if (user_status[1]) { return user_status[1]; @@ -684,7 +684,7 @@ } /* Allocate request block */ - rrq* request = (rrq*) ALLR_block(type_rrq, max_msg + 1); + Rrq* request = new Rrq(max_msg + 1); *req_handle = request; request->rrq_rdb = rdb; request->rrq_id = packet->p_resp.p_resp_object; @@ -706,7 +706,7 @@ message->msg_prior = message; #endif - rrq::rrq_repeat * tail = request->rrq_rpt + message->msg_number; + Rrq::rrq_repeat * tail = &request->rrq_rpt[message->msg_number]; tail->rrq_message = message; tail->rrq_xdr = message; #ifdef SCROLLABLE_CURSORS @@ -781,15 +781,13 @@ if (user_status[1]) return user_status[1]; - RBL blob = (RBL) ALLR_block(type_rbl, BLOB_LENGTH); + RBL blob = new Rbl(); *blob_handle = blob; *blob_id = packet->p_resp.p_resp_blob_id; - blob->rbl_buffer_length = BLOB_LENGTH; blob->rbl_rdb = rdb; blob->rbl_rtr = transaction; blob->rbl_id = packet->p_resp.p_resp_object; - blob->rbl_ptr = blob->rbl_buffer = blob->rbl_data; - blob->rbl_flags |= RBL_create; + blob->rbl_flags |= Rbl::CREATE; SET_OBJECT(rdb, blob, blob->rbl_id); blob->rbl_next = transaction->rtr_blobs; transaction->rtr_blobs = blob; @@ -901,7 +899,7 @@ * **************************************/ ISC_STATUS status; - UCHAR temp[1024]; + Firebird::HalfStaticArray<UCHAR, 1024> temp; RDB rdb = *handle; CHECK_HANDLE(rdb, type_rdb, isc_bad_db_handle); @@ -912,12 +910,7 @@ try { - UCHAR* temp_buffer = temp; - if (buffer_length > (SLONG) sizeof(temp)) { - temp_buffer = ALLR_alloc((SLONG) buffer_length); - } - /* NOMEM: ALLR_alloc handled */ - /* FREE: Normal case later in this procedure, what about error to ERROR_INIT? */ + UCHAR* temp_buffer = temp.getBuffer(buffer_length); status = info(user_status, rdb, op_info_database, rdb->rdb_id, 0, item_length, items, 0, 0, buffer_length, @@ -933,10 +926,6 @@ reinterpret_cast<const UCHAR*>(version.c_str()), reinterpret_cast<const UCHAR*>(port->port_host->str_data), 0); } - - if (temp_buffer != temp) { - ALLR_free(temp_buffer); - } } catch (const Firebird::Exception& ex) { @@ -1175,10 +1164,10 @@ RSR statement; if (rdb->rdb_port->port_flags & PORT_lazy) { - *stmt_handle = statement = (RSR) ALLR_block(type_rsr, 0); + *stmt_handle = statement = new Rsr; statement->rsr_rdb = rdb; statement->rsr_id = INVALID_OBJECT; - statement->rsr_flags |= RSR_lazy; + statement->rsr_flags |= Rsr::LAZY; } else { PACKET* packet = &rdb->rdb_packet; @@ -1190,7 +1179,7 @@ /* Allocate SQL request block */ - statement = (RSR) ALLR_block(type_rsr, 0); + statement = new Rsr; *stmt_handle = statement; statement->rsr_rdb = rdb; statement->rsr_id = packet->p_resp.p_resp_object; @@ -1293,12 +1282,10 @@ // previous executions (possibly with different statement if // isc_dsql_prepare is called multiple times). // This should cure SF#919246 - if (statement->rsr_bind_format) { - ALLR_free(statement->rsr_bind_format); + delete statement->rsr_bind_format; statement->rsr_bind_format = NULL; - } - if (port->port_statement && port->port_statement->rsr_select_format) { - ALLR_free(port->port_statement->rsr_select_format); + if (port->port_statement) { + delete port->port_statement->rsr_select_format; port->port_statement->rsr_select_format = NULL; } @@ -1308,7 +1295,7 @@ REM_MSG message = PARSE_messages(in_blr, in_blr_length); if (message != (REM_MSG) - 1) { statement->rsr_bind_format = (rem_fmt*) message->msg_address; - ALLR_free(message); + delete message; } } @@ -1317,17 +1304,17 @@ if (out_blr_length) { if (!port->port_statement) - port->port_statement = (RSR) ALLR_block(type_rsr, 0); + port->port_statement = new Rsr; REM_MSG message = PARSE_messages(out_blr, out_blr_length); if (message != (REM_MSG) - 1) { port->port_statement->rsr_select_format = (rem_fmt*) message->msg_address; - ALLR_free(message); + delete message; } if (!port->port_statement->rsr_buffer) { - REM_MSG message2 = (REM_MSG) ALLR_block(type_msg, 0); + REM_MSG message2 = new Message(0); port->port_statement->rsr_buffer = message2; port->port_statement->rsr_message = message2; message2->msg_next = message2; @@ -1340,7 +1327,7 @@ REM_MSG message = 0; if (!statement->rsr_buffer) { - statement->rsr_buffer = message = (REM_MSG) ALLR_block(type_msg, 0); + statement->rsr_buffer = message = new Message(0); statement->rsr_message = message; message->msg_next = message; @@ -1355,7 +1342,7 @@ } message->msg_address = in_msg; - statement->rsr_flags &= ~RSR_fetched; + statement->rsr_flags &= ~Rsr::FETCHED; statement->rsr_format = statement->rsr_bind_format; stmt_clear_exception(statement); @@ -1374,7 +1361,7 @@ sqldata->p_sqldata_out_blr.cstr_address = out_blr; sqldata->p_sqldata_out_message_number = out_msg_type; - if (out_msg_length || !(statement->rsr_flags & RSR_defer_execute)) + if (out_msg_length || !(statement->rsr_flags & Rsr::DEFER_EXECUTE)) { if (!send_packet(port, packet, user_status)) return user_status[1]; @@ -1533,7 +1520,7 @@ RSR statement = port->port_statement; if (!statement) { - statement = port->port_statement = (RSR) ALLR_block(type_rsr, 0); + statement = port->port_statement = new Rsr; } /* reset statement buffers */ @@ -1543,15 +1530,10 @@ REMOTE_reset_statement(statement); - if (statement->rsr_bind_format) { - ALLR_free(statement->rsr_bind_format); + delete statement->rsr_bind_format; statement->rsr_bind_format = NULL; - } - - if (statement->rsr_select_format) { - ALLR_free(statement->rsr_select_format); + delete statement->rsr_select_format; statement->rsr_select_format = NULL; - } if (in_msg_length || out_msg_length) { @@ -1560,7 +1542,7 @@ REM_MSG message = PARSE_messages(in_blr, in_blr_length); if ((message) != (REM_MSG) - 1) { statement->rsr_bind_format = (rem_fmt*) message->msg_address; - ALLR_free(message); + delete message; } } if (out_blr_length) @@ -1568,7 +1550,7 @@ REM_MSG message = PARSE_messages(out_blr, out_blr_length); if ((message) != (REM_MSG) - 1) { statement->rsr_select_format = (rem_fmt*) message->msg_address; - ALLR_free(message); + delete message; } } } @@ -1576,7 +1558,7 @@ REM_MSG message = 0; if (!statement->rsr_buffer) { - statement->rsr_buffer = message = (REM_MSG) ALLR_block(type_msg, 0); + statement->rsr_buffer = message = new Message(0); statement->rsr_message = message; message->msg_next = message; #ifdef SCROLLABLE_CURSORS @@ -1697,11 +1679,11 @@ /* On first fetch, clear the end-of-stream flag & reset the message buffers */ - if (!(statement->rsr_flags & RSR_fetched)) + if (!(statement->rsr_flags & Rsr::FETCHED)) { stmt_raise_exception(statement); - statement->rsr_flags &= ~(RSR_eof | RSR_stream_err | RSR_past_eof); + statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR | Rsr::PAST_EOF); statement->rsr_rows_pending = 0; stmt_clear_exception(statement); @@ -1719,8 +1701,8 @@ } } } - else if ((statement->rsr_flags & RSR_eof) && - (statement->rsr_flags & RSR_past_eof)) + else if ((statement->rsr_flags & Rsr::EOF_SET) && + (statement->rsr_flags & Rsr::PAST_EOF)) { user_status[0] = isc_arg_gds; user_status[1] = isc_req_sync; @@ -1733,24 +1715,25 @@ if (blr_length) { if (statement->rsr_user_select_format && statement->rsr_user_select_format != statement->rsr_select_format) - ALLR_free(statement->rsr_user_select_format); + { + delete statement->rsr_user_select_format; + } REM_MSG message = PARSE_messages(blr, blr_length); if (message != (REM_MSG) - 1) { statement->rsr_user_select_format = (rem_fmt*) message->msg_address; - ALLR_free(message); + delete message; } else statement->rsr_user_select_format = NULL; - if (statement->rsr_flags & RSR_fetched) + if (statement->rsr_flags & Rsr::FETCHED) blr_length = 0; else { - if (statement->rsr_select_format) - ALLR_free(statement->rsr_select_format); + delete statement->rsr_select_format; statement->rsr_select_format = statement->rsr_user_select_format; } } - if (statement->rsr_flags & RSR_blob) { + if (statement->rsr_flags & Rsr::BLOB) { status = fetch_blob(user_status, statement, blr_length, blr, msg_type, msg_length, msg); return status; @@ -1758,7 +1741,7 @@ if (!statement->rsr_buffer) { - statement->rsr_buffer = (REM_MSG) ALLR_block(type_msg, 0); + statement->rsr_buffer = new Message(0); statement->rsr_message = statement->rsr_buffer; statement->rsr_message->msg_next = statement->rsr_message; #ifdef SCROLLABLE_CURSORS @@ -1776,7 +1759,7 @@ /* Check to see if data is waiting. If not, solicite data. */ - if ((!(statement->rsr_flags & (RSR_eof | RSR_stream_err)) && + if ((!(statement->rsr_flags & (Rsr::EOF_SET | Rsr::STREAM_ERR)) && (!statement->rsr_message->msg_address) && (statement->rsr_rows_pending == 0)) || ( /* Low in inventory */ @@ -1791,12 +1774,10 @@ block for the other end to read - and so when both attempt to write simultaenously, they end up waiting indefinetly for the other end to read */ - (port->port_type != port_pipe) && -#ifdef XNET - (port->port_type != port_xnet) && -#endif + (port->port_type != rem_port::PIPE) && + (port->port_type != rem_port::XNET) && /* We've reached eof or there was an error */ - !(statement->rsr_flags & (RSR_eof | RSR_stream_err)) && + !(statement->rsr_flags & (Rsr::EOF_SET | Rsr::STREAM_ERR)) && /* No error pending */ (!stmt_have_exception(statement) ))) { @@ -1855,10 +1836,10 @@ fb_assert(statement->rsr_msgs_waiting || (statement->rsr_rows_pending > 0) || stmt_have_exception(statement) - || statement->rsr_flags & (RSR_eof)); + || statement->rsr_flags & (Rsr::EOF_SET)); while (!stmt_have_exception(statement) /* received a database error */ - &&!(statement->rsr_flags & (RSR_eof)) /* reached end of cursor */ + &&!(statement->rsr_flags & (Rsr::EOF_SET)) /* reached end of cursor */ &&!(statement->rsr_msgs_waiting >= 2) /* Have looked ahead for end of batch */ &&!(statement->rsr_rows_pending == 0)) { /* Hit end of batch */ @@ -1870,7 +1851,7 @@ if (!statement->rsr_msgs_waiting) { - if (statement->rsr_flags & RSR_eof) + if (statement->rsr_flags & Rsr::EOF_SET) { // hvlad: we may have queued fetch packet but received EOF before start // handling of this packet. Handle it now. @@ -1878,17 +1859,17 @@ return user_status[1]; } - // hvlad: as we processed all queued packets at code above we can leave RSR_eof flag. + // hvlad: as we processed all queued packets at code above we can leave Rsr::EOF_SET flag. // It allows us to return EOF for all subsequent isc_dsql_fetch calls until statement // will be re-executed (and without roundtrip to remote server). - //statement->rsr_flags &= ~RSR_eof; - statement->rsr_flags |= RSR_past_eof; + //statement->rsr_flags &= ~Rsr::EOF_SET; + statement->rsr_flags |= Rsr::PAST_EOF; return_success(rdb); return 100; } - if (statement->rsr_flags & RSR_stream_err) { + if (statement->rsr_flags & Rsr::STREAM_ERR) { /* The previous batch of receives ended with an error status. We're all done returning data in the local queue. @@ -1896,10 +1877,10 @@ /* Stuff in the error result to the user's vector */ - statement->rsr_flags &= ~RSR_stream_err; + statement->rsr_flags &= ~Rsr::STREAM_ERR; // hvlad: prevent subsequent fetches - statement->rsr_flags |= RSR_eof | RSR_past_eof; + statement->rsr_flags |= Rsr::EOF_SET | Rsr::PAST_EOF; if (statement->rsr_status) { memcpy(user_status, statement->rsr_status->value(), @@ -1975,13 +1956,13 @@ return unsupported(user_status); } - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { if (option == DSQL_drop) { release_sql_request(statement); *stmt_handle = NULL; } else { - statement->rsr_flags &= ~RSR_fetched; + statement->rsr_flags &= ~Rsr::FETCHED; statement->rsr_rtr = NULL; if (!clear_queue(rdb->rdb_port, user_status)) @@ -2020,7 +2001,7 @@ *stmt_handle = NULL; } else { - statement->rsr_flags &= ~RSR_fetched; + statement->rsr_flags &= ~Rsr::FETCHED; statement->rsr_rtr = NULL; if (!clear_queue(rdb->rdb_port, user_status)) @@ -2075,10 +2056,8 @@ // Free existing format unconditionally. // This is also related to SF#919246 - if (statement->rsr_bind_format) { - ALLR_free(statement->rsr_bind_format); + delete statement->rsr_bind_format; statement->rsr_bind_format = NULL; - } /* Parse the blr describing the message, if there is any. */ @@ -2086,13 +2065,13 @@ REM_MSG message = PARSE_messages(blr, blr_length); if (message != (REM_MSG) - 1) { statement->rsr_bind_format = (rem_fmt*) message->msg_address; - ALLR_free(message); + delete message; } } REM_MSG message = 0; if (!statement->rsr_buffer) { - statement->rsr_buffer = message = (REM_MSG) ALLR_block(type_msg, 0); + statement->rsr_buffer = message = new Message(0); statement->rsr_message = message; message->msg_next = message; #ifdef SCROLLABLE_CURSORS @@ -2111,7 +2090,7 @@ PACKET* packet = &rdb->rdb_packet; - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { packet->p_operation = op_allocate_statement; packet->p_rlse.p_rlse_object = rdb->rdb_id; @@ -2133,14 +2112,14 @@ message->msg_address = NULL; - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { if (!receive_response(rdb, packet)) return user_status[1]; statement->rsr_id = packet->p_resp.p_resp_object; SET_OBJECT(rdb, statement, statement->rsr_id); - statement->rsr_flags &= ~RSR_lazy; + statement->rsr_flags &= ~Rsr::LAZY; } if (!receive_response(rdb, packet)) { @@ -2218,7 +2197,7 @@ PACKET* packet = &rdb->rdb_packet; - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { packet->p_operation = op_allocate_statement; packet->p_rlse.p_rlse_object = rdb->rdb_id; @@ -2241,18 +2220,18 @@ if (!send_packet(rdb->rdb_port, packet, user_status)) return user_status[1]; - statement->rsr_flags &= ~(RSR_blob | RSR_defer_execute); + statement->rsr_flags &= ~(Rsr::BLOB | Rsr::DEFER_EXECUTE); /* Set up for the response packet. */ - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { if (!receive_response(rdb, packet)) return user_status[1]; statement->rsr_id = packet->p_resp.p_resp_object; SET_OBJECT(rdb, statement, statement->rsr_id); - statement->rsr_flags &= ~RSR_lazy; + statement->rsr_flags &= ~Rsr::LAZY; } P_RESP* response = &packet->p_resp; @@ -2265,16 +2244,16 @@ if (rdb->rdb_port->port_flags & PORT_lazy) { if (response->p_resp_object & STMT_BLOB) { - statement->rsr_flags |= RSR_blob; + statement->rsr_flags |= Rsr::BLOB; } if (response->p_resp_object & STMT_DEFER_EXECUTE) { - statement->rsr_flags |= RSR_defer_execute; + statement->rsr_flags |= Rsr::DEFER_EXECUTE; } } else { if (response->p_resp_object) - statement->rsr_flags |= RSR_blob; + statement->rsr_flags |= Rsr::BLOB; } response->p_resp_data = temp; @@ -2348,7 +2327,7 @@ PACKET* packet = &rdb->rdb_packet; - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { packet->p_operation = op_allocate_statement; packet->p_rlse.p_rlse_object = rdb->rdb_id; @@ -2369,14 +2348,14 @@ return user_status[1]; } - if (statement->rsr_flags & RSR_lazy) { + if (statement->rsr_flags & Rsr::LAZY) { if (!receive_response(rdb, packet)) return user_status[1]; statement->rsr_id = packet->p_resp.p_resp_object; SET_OBJECT(rdb, statement, statement->rsr_id); - statement->rsr_flags &= ~RSR_lazy; + statement->rsr_flags &= ~Rsr::LAZY; } if (!receive_response(rdb, packet)) { @@ -2485,7 +2464,7 @@ /* Handle old protocol. Also handle new protocol on a blob that has been created rather than opened. (This should yield an error.) */ - if ((port->port_flags & PORT_rpc) || (blob->rbl_flags & RBL_create)) + if ((port->port_flags & PORT_rpc) || (blob->rbl_flags & Rbl::CREATE)) { packet->p_operation = op_get_segment; segment->p_sgmt_length = buffer_length; @@ -2523,7 +2502,7 @@ /* if we're already done, stop now */ - if (blob->rbl_flags & RBL_eof) { + if (blob->rbl_flags & Rbl::EOF_SET) { *v++ = isc_segstr_eof; return user_status[1]; } @@ -2568,7 +2547,7 @@ incomplete read */ if (l == buffer_length && - l == blob->rbl_length && (blob->rbl_flags & RBL_segment)) + l == blob->rbl_length && (blob->rbl_flags & Rbl::SEGMENT)) { *v = isc_segment; } @@ -2593,7 +2572,7 @@ segment */ if (!buffer_length || - blob->rbl_length || !(blob->rbl_flags & RBL_segment)) + blob->rbl_length || !(blob->rbl_flags & Rbl::SEGMENT)) { break; } @@ -2601,8 +2580,8 @@ /* We're done with buffer. If this was the last, we're done */ - if (blob->rbl_flags & RBL_eof_pending) { - blob->rbl_flags |= RBL_eof; + if (blob->rbl_flags & Rbl::EOF_PENDING) { + blob->rbl_flags |= Rbl::EOF_SET; *v = isc_segstr_eof; break; } @@ -2624,11 +2603,7 @@ if (new_size > MAX_USHORT) /* Check if we've overflown */ new_size = buffer_length; - if (blob->rbl_buffer != blob->rbl_data) - ALLR_free(blob->rbl_buffer); - blob->rbl_ptr = blob->rbl_buffer = ALLR_alloc((SLONG) new_size); - /* NOMEM: ALLR_alloc handled */ - /* FREE: in release_blob() */ + blob->rbl_ptr = blob->rbl_buffer = blob->rbl_data.getBuffer(new_size); blob->rbl_buffer_length = (USHORT) new_size; } @@ -2651,11 +2626,11 @@ blob->rbl_length = response->p_resp_data.cstr_length; blob->rbl_ptr = blob->rbl_buffer; - blob->rbl_flags &= ~RBL_segment; + blob->rbl_flags &= ~Rbl::SEGMENT; if (response->p_resp_object == 1) - blob->rbl_flags |= RBL_segment; + blob->rbl_flags |= Rbl::SEGMENT; else if (response->p_resp_object == 2) - blob->rbl_flags |= RBL_eof_pending; + blob->rbl_flags |= Rbl::EOF_PENDING; } response->p_resp_data = temp; @@ -2830,15 +2805,13 @@ //p_blob->p_blob_bpb.cstr_length = 0; //p_blob->p_blob_bpb.cstr_address = NULL; - RBL blob = (RBL) ALLR_block(type_rbl, BLOB_LENGTH); + RBL blob = new Rbl; *blob_handle = blob; blob->rbl_rdb = rdb; blob->rbl_rtr = transaction; blob->rbl_id = packet->p_resp.p_resp_object; - blob->rbl_buffer_length = BLOB_LENGTH; SET_OBJECT(rdb, blob, blob->rbl_id); blob->rbl_next = transaction->rtr_blobs; - blob->rbl_ptr = blob->rbl_buffer = blob->rbl_data; transaction->rtr_blobs = blob; } catch (const Firebird::Exception& ex) @@ -2944,7 +2917,7 @@ Also handle the new protocol on a blob that has been opened rather than created. (This should yield an error.) */ - if ((port->port_flags & PORT_rpc) || !(blob->rbl_flags & RBL_create)) + if ((port->port_flags & PORT_rpc) || !(blob->rbl_flags & Rbl::CREATE)) { send_blob(user_status, blob, segment_length, segment); return user_status[1]; @@ -3186,7 +3159,7 @@ ISC_STATUS GDS_RECEIVE(ISC_STATUS * user_status, - rrq** req_handle, + Rrq** req_handle, USHORT msg_type, USHORT msg_length, UCHAR * msg, SSHORT level #ifdef SCROLLABLE_CURSORS @@ -3209,7 +3182,7 @@ /* Check handles and environment, then set up error handling */ CHECK_HANDLE((*req_handle), type_rrq, isc_bad_req_handle); - rrq* request = REMOTE_find_request(*req_handle, level); + Rrq* request = REMOTE_find_request(*req_handle, level); RDB rdb = request->rrq_rdb; CHECK_HANDLE(rdb, type_rdb, isc_bad_db_handle); @@ -3220,7 +3193,7 @@ try { - rrq::rrq_repeat* tail = &request->rrq_rpt[msg_type]; + Rrq::rrq_repeat* tail = &request->rrq_rpt[msg_type]; REM_MSG message = tail->rrq_message; #ifdef SCROLLABLE_CURSORS @@ -3259,10 +3232,8 @@ block for the other end to read - and so when both attempt to write simultaenously, they end up waiting indefinetly for the other end to read */ - (port->port_type != port_pipe) && /* not named pipe on NT */ -#ifdef XNET - (port->port_type != port_xnet) && /* not named pipe on NT */ -#endif + (port->port_type != rem_port::PIPE) && /* not named pipe on NT */ + (port->port_type != rem_port::XNET) && /* not named pipe on NT */ request->rrq_max_msg <= 1))) { /* there's only one message type */ @@ -3295,29 +3266,29 @@ switch (direction) { case blr_forward: - tail->rrq_flags &= ~RRQ_backward; + tail->rrq_flags &= ~Rrq::BACKWARD; tail->rrq_absolute += - (tail->rrq_flags & RRQ_absolute_backward) ? + (tail->rrq_flags & Rrq::ABSOLUTE_BACKWARD) ? -offset : offset; break; case blr_backward: - tail->rrq_flags |= RRQ_backward; + tail->rrq_flags |= Rrq::BACKWARD; tail->rrq_absolute += - (tail->rrq_flags & RRQ_absolute_backward) ? + (tail->rrq_flags & Rrq::ABSOLUTE_BACKWARD) ? offset : -offset; break; case blr_bof_forward: - tail->rrq_flags &= ~RRQ_backward; - tail->rrq_flags &= ~RRQ_absolute_backward; + tail->rrq_flags &= ~Rrq::BACKWARD; + tail->rrq_flags &= ~Rrq::ABSOLUTE_BACKWARD; tail->rrq_absolute = offset; direction = blr_forward; break; case blr_eof_backward: - tail->rrq_flags |= RRQ_backward; - tail->rrq_flags |= RRQ_absolute_backward; + tail->rrq_flags |= Rrq::BACKWARD; + tail->rrq_flags |= Rrq::ABSOLUTE_BACKWARD; tail->rrq_absolute = offset; direction = blr_backward; break; @@ -3480,7 +3451,7 @@ } -ISC_STATUS GDS_RELEASE_REQUEST(ISC_STATUS * user_status, rrq** req_handle) +ISC_STATUS GDS_RELEASE_REQUEST(ISC_STATUS * user_status, Rrq** req_handle) { /************************************** * @@ -3492,7 +3463,7 @@ * Release a request. * **************************************/ - rrq* request = *req_handle; + Rrq* request = *req_handle; CHECK_HANDLE(request, type_rrq, isc_bad_req_handle); RDB rdb = request->rrq_rdb; @@ -3521,7 +3492,7 @@ ISC_STATUS GDS_REQUEST_INFO(ISC_STATUS* user_status, - rrq** req_handle, + Rrq** req_handle, SSHORT level, SSHORT item_length, const UCHAR* items, SSHORT buffer_length, UCHAR* buffer) @@ -3538,7 +3509,7 @@ **************************************/ ISC_STATUS status; - rrq* request = REMOTE_find_request(*req_handle, level); + Rrq* request = REMOTE_find_request(*req_handle, level); CHECK_HANDLE(request, type_rrq, isc_bad_req_handle); RDB rdb = request->rrq_rdb; @@ -3551,8 +3522,8 @@ try { /* Check for buffered message. If there is, report on it locally. */ - const rrq::rrq_repeat* tail= request->rrq_rpt; - for (const rrq::rrq_repeat* const end = tail + request->rrq_max_msg; + const Rrq::rrq_repeat* tail= request->rrq_rpt.begin(); + for (const Rrq::rrq_repeat* const end = tail + request->rrq_max_msg; tail <= end; tail++) { REM_MSG msg = tail->rrq_message; @@ -3753,7 +3724,7 @@ blob->rbl_offset = *result = packet->p_resp.p_resp_blob_id.bid_quad_low; blob->rbl_length = 0; blob->rbl_fragment_length = 0; - blob->rbl_flags &= ~(RBL_eof | RBL_eof_pending | RBL_segment); + blob->rbl_flags &= ~(Rbl::EOF_SET | Rbl::EOF_PENDING | Rbl::SEGMENT); } catch (const Firebird::Exception& ex) { @@ -3765,7 +3736,7 @@ ISC_STATUS GDS_SEND(ISC_STATUS * user_status, - rrq** req_handle, + Rrq** req_handle, USHORT msg_type, USHORT msg_length, UCHAR * msg, SSHORT level) { /************************************** @@ -3779,7 +3750,7 @@ * **************************************/ CHECK_HANDLE((*req_handle), type_rrq, isc_bad_req_handle); - rrq* request = REMOTE_find_request(*req_handle, level); + Rrq* request = REMOTE_find_request(*req_handle, level); RDB rdb = request->rrq_rdb; CHECK_HANDLE(rdb, type_rdb, isc_bad_db_handle); @@ -4065,7 +4036,7 @@ ISC_STATUS GDS_START_AND_SEND(ISC_STATUS * user_status, - rrq** req_handle, + Rrq** req_handle, RTR* rtr_handle, USHORT msg_type, USHORT msg_length, UCHAR * msg, SSHORT level) @@ -4082,7 +4053,7 @@ **************************************/ CHECK_HANDLE((*req_handle), type_rrq, isc_bad_req_handle); CHECK_HANDLE((*rtr_handle), type_rtr, isc_bad_trans_handle); - rrq* request = REMOTE_find_request(*req_handle, level); + Rrq* request = REMOTE_find_request(*req_handle, level); RTR transaction = *rtr_handle; RDB rdb = request->rrq_rdb; @@ -4152,7 +4123,7 @@ ISC_STATUS GDS_START(ISC_STATUS * user_status, - rrq** req_handle, + Rrq** req_handle, RTR* rtr_handle, USHORT level) { /************************************** @@ -4167,7 +4138,7 @@ **************************************/ CHECK_HANDLE((*req_handle), type_rrq, isc_bad_req_handle); CHECK_HANDLE((*rtr_handle), type_rtr, isc_bad_trans_handle); - rrq* request = REMOTE_find_request(*req_handle, level); + Rrq* request = REMOTE_find_request(*req_handle, level); RTR transaction = *rtr_handle; RDB rdb = request->rrq_rdb; @@ -4314,7 +4285,7 @@ RPR procedure = port->port_rpr; if (!procedure) { - procedure = port->port_rpr = (RPR) ALLR_block(type_rpr, 0); + procedure = port->port_rpr = new rpr; } if ((*rtr_handle)->rtr_rdb != rdb) { @@ -4326,22 +4297,14 @@ /* Parse the blr describing the messages */ - if (procedure->rpr_in_msg) { - ALLR_free(procedure->rpr_in_msg); + delete procedure->rpr_in_msg; procedure->rpr_in_msg = NULL; - } - if (procedure->rpr_in_format) { - ALLR_free(procedure->rpr_in_format); + delete procedure->rpr_in_format; procedure->rpr_in_format = NULL; - } - if (procedure->rpr_out_msg) { - ALLR_free(procedure->rpr_out_msg); + delete procedure->rpr_out_msg; procedure->rpr_out_msg = NULL; - } - if (procedure->rpr_out_format) { - ALLR_free(procedure->rpr_out_format); + delete procedure->rpr_out_format; procedure->rpr_out_format = NULL; - } REM_MSG message = PARSE_messages(blr, blr_length); if (message != (REM_MSG) - 1) { @@ -4365,7 +4328,7 @@ default: REM_MSG temp = message; message = message->msg_next; - ALLR_free(temp); + delete temp; break; } } @@ -4456,7 +4419,7 @@ } -ISC_STATUS GDS_UNWIND(ISC_STATUS* user_status, rrq** req_handle, USHORT level) +ISC_STATUS GDS_UNWIND(ISC_STATUS* user_status, Rrq** req_handle, USHORT level) { /************************************** * @@ -4468,7 +4431,7 @@ * Unwind a running request. * **************************************/ - rrq* request = REMOTE_find_request(*req_handle, level); + Rrq* request = REMOTE_find_request(*req_handle, level); CHECK_HANDLE(request, type_rrq, isc_bad_req_handle); RDB rdb = request->rrq_rdb; @@ -4514,7 +4477,7 @@ } if (!event) { - event = (RVNT) ALLR_block(type_rvnt, 0); + event = new rvnt; event->rvnt_next = rdb->rdb_events; rdb->rdb_events = event; } @@ -4875,7 +4838,7 @@ fb_assert(que_inst->rmtque_function == batch_dsql_fetch); RDB rdb = que_inst->rmtque_rdb; - RSR statement = static_cast<rsr*>(que_inst->rmtque_parm); + RSR statement = static_cast<Rsr*>(que_inst->rmtque_parm); PACKET* packet = &rdb->rdb_packet; fb_assert(port == rdb->rdb_port); @@ -4900,11 +4863,11 @@ /* In addtion to the above we grab all the records in case of XNET as * we need to clear the queue */ bool clear_queue = false; - if (id != statement->rsr_id || port->port_type == port_xnet) { + if (id != statement->rsr_id || port->port_type == rem_port::XNET) { clear_queue = true; } - statement->rsr_flags |= RSR_fetched; + statement->rsr_flags |= Rsr::FETCHED; while (true) { /* Swallow up data. If a buffer isn't available, allocate another. */ @@ -4912,7 +4875,7 @@ REM_MSG message = statement->rsr_buffer; if (message->msg_address) { - REM_MSG new_msg = (REM_MSG) ALLR_block(type_msg, statement->rsr_fmt_length); + REM_MSG new_msg = new Message(statement->rsr_fmt_length); statement->rsr_buffer = new_msg; new_msg->msg_next = message; @@ -4945,7 +4908,7 @@ } if (packet->p_operation != op_fetch_response) { - statement->rsr_flags |= RSR_stream_err; + statement->rsr_flags |= Rsr::STREAM_ERR; check_response(rdb, packet); /* save the status vector in a safe place */ @@ -4966,7 +4929,7 @@ { if (packet->p_sqldata.p_sqldata_status == 100) { - statement->rsr_flags |= RSR_eof; + statement->rsr_flags |= Rsr::EOF_SET; statement->rsr_rows_pending = 0; #ifdef DEBUG fprintf(stdout, @@ -5036,8 +4999,8 @@ fb_assert(que_inst->rmtque_function == batch_gds_receive); RDB rdb = que_inst->rmtque_rdb; - rrq* request = static_cast<rrq*>(que_inst->rmtque_parm); - rrq::rrq_repeat* tail = que_inst->rmtque_message; + Rrq* request = static_cast<Rrq*>(que_inst->rmtque_parm); + Rrq::rrq_repeat* tail = que_inst->rmtque_message; PACKET *packet = &rdb->rdb_packet; fb_assert(port == rdb->rdb_port); @@ -5053,7 +5016,7 @@ // always clear the complete queue for XNET, as we might // have incomplete packets - if (id != request->rrq_id || port->port_type == port_xnet) { + if (id != request->rrq_id || port->port_type == rem_port::XNET) { clear_queue = true; } @@ -5071,7 +5034,7 @@ if (message->msg_address) { const rem_fmt* format = tail->rrq_format; - REM_MSG new_msg = (REM_MSG) ALLR_block(type_msg, format->fmt_length); + REM_MSG new_msg = new Message(format->fmt_length); tail->rrq_xdr = new_msg; new_msg->msg_next = message; new_msg->msg_number = message->msg_number; @@ -5129,8 +5092,8 @@ #ifdef SCROLLABLE_CURSORS /* at this point we've received a row into the message, so mark the message with the absolute offset */ - const bool bIsBackward = (tail->rrq_flags & RRQ_backward) != 0; - const bool bIsAbsBackward = (tail->rrq_flags & RRQ_absolute_backward) != 0; + const bool bIsBackward = (tail->rrq_flags & Rrq::BACKWARD) != 0; + const bool bIsAbsBackward = (tail->rrq_flags & Rrq::ABSOLUTE_BACKWARD) != 0; if (bIsBackward == bIsAbsBackward) { tail->rrq_absolute++; @@ -5304,7 +5267,7 @@ */ - if (port->port_type != port_pipe) { + if (port->port_type != rem_port::PIPE) { packet->p_operation = op_disconnect; port->send(packet); } @@ -5326,16 +5289,13 @@ memory for remote database context. */ port->disconnect(); - - if (rdb) { - ALLR_free(rdb); - } + delete rdb; } #ifdef SCROLLABLE_CURSORS static REM_MSG dump_cache( - rem_port* port, ISC_STATUS * user_status, rrq::rrq_repeat * tail) + rem_port* port, ISC_STATUS * user_status, Rrq::rrq_repeat * tail) { /************************************** * @@ -5822,7 +5782,7 @@ * Create a local transaction handle. * **************************************/ - RTR transaction = (RTR) ALLR_block(type_rtr, 0); + RTR transaction = new Rtr; transaction->rtr_rdb = rdb; transaction->rtr_id = id; transaction->rtr_next = rdb->rdb_transactions; @@ -5857,8 +5817,8 @@ /* Msg 263 SQLDA missing or wrong number of variables */ } - const dsc* from_desc = from_fmt->fmt_desc; - const dsc* to_desc = to_fmt->fmt_desc; + const dsc* from_desc = from_fmt->fmt_desc.begin(); + const dsc* to_desc = to_fmt->fmt_desc.begin(); const dsc* const end_desc = to_desc + to_fmt->fmt_count; for (; to_desc < end_desc; from_desc++, to_desc++) { dsc from = *from_desc; @@ -5928,7 +5888,7 @@ } -static void receive_after_start( rrq* request, USHORT msg_type) +static void receive_after_start( Rrq* request, USHORT msg_type) { /***************************************** * @@ -5955,7 +5915,7 @@ RDB rdb = request->rrq_rdb; rem_port* port = rdb->rdb_port; PACKET* packet = &rdb->rdb_packet; - rrq::rrq_repeat* tail = &request->rrq_rpt[msg_type]; + Rrq::rrq_repeat* tail = &request->rrq_rpt[msg_type]; // CVC: I commented this line because it's overwritten immediately in the loop. // REM_MSG message = tail->rrq_message; const rem_fmt* format = tail->rrq_format; @@ -5971,7 +5931,7 @@ while (true) { REM_MSG message = tail->rrq_xdr; if (message->msg_address) { - REM_MSG new_msg = (REM_MSG) ALLR_block(type_msg, format->fmt_length); + REM_MSG new_msg = new Message(format->fmt_length); tail->rrq_xdr = new_msg; new_msg->msg_next = message; new_msg->msg_number = message->msg_number; @@ -6127,7 +6087,7 @@ RSR statement = NULL; if (bCheckResponse || bFreeStmt) { - statement = (RSR) port->port_objects[stmt_id]; + statement = port->port_objects[stmt_id]; CHECK_HANDLE(statement, type_rsr, isc_bad_req_handle); } @@ -6143,7 +6103,7 @@ { // assign statement to transaction const OBJCT tran_id = p->packet.p_sqldata.p_sqldata_transaction; - RTR transaction = (RTR) port->port_objects[tran_id]; + RTR transaction = port->port_objects[tran_id]; statement->rsr_rtr = transaction; } } @@ -6205,7 +6165,7 @@ t_rmtque_fn fn, RDB rdb, void* parm, - rrq::rrq_repeat* parm1) + Rrq::rrq_repeat* parm1) { /************************************** * @@ -6216,7 +6176,7 @@ * Functional description * **************************************/ - RMTQUE que_inst = (RMTQUE) ALLR_block(type_rmtque, 0); + RMTQUE que_inst = new rmtque; /* Prepare a queue entry */ @@ -6257,7 +6217,7 @@ /* Add queue entry onto free queue */ - ALLR_free(que_inst); + delete que_inst; } @@ -6298,7 +6258,7 @@ **************************************/ RTR transaction = blob->rbl_rtr; RDB rdb = blob->rbl_rdb; - SET_OBJECT(rdb, NULL, blob->rbl_id); + rdb->rdb_port->releaseObject(blob->rbl_id); for (RBL* p = &transaction->rtr_blobs; *p; p = &(*p)->rbl_next) { @@ -6308,10 +6268,7 @@ } } - if (blob->rbl_buffer != blob->rbl_data) - ALLR_free(blob->rbl_buffer); - - ALLR_free(blob); + delete blob; } @@ -6337,7 +6294,7 @@ } } - ALLR_free(event); + delete event; } @@ -6380,7 +6337,7 @@ } -static void release_request( rrq* request) +static void release_request( Rrq* request) { /************************************** * @@ -6393,7 +6350,7 @@ * **************************************/ RDB rdb = request->rrq_rdb; - SET_OBJECT(rdb, NULL, request->rrq_id); + rdb->rdb_port->releaseObject(request->rrq_id); REMOTE_release_request(request); } @@ -6411,23 +6368,19 @@ * **************************************/ - if ((*statement)->rsr_bind_format) { - ALLR_free((*statement)->rsr_bind_format); - } + delete (*statement)->rsr_bind_format; if ((*statement)->rsr_user_select_format && (*statement)->rsr_user_select_format != (*statement)->rsr_select_format) { - ALLR_free((*statement)->rsr_user_select_format); - } - if ((*statement)->rsr_select_format) { - ALLR_free((*statement)->rsr_select_format); + delete (*statement)->rsr_user_select_format; } + delete (*statement)->rsr_select_format; stmt_release_exception(*statement); REMOTE_release_messages((*statement)->rsr_message); - ALLR_free((*statement)); - (*statement) = NULL; + delete *statement; + *statement = NULL; } @@ -6444,7 +6397,7 @@ * **************************************/ RDB rdb = statement->rsr_rdb; - SET_OBJECT(rdb, NULL, statement->rsr_id); + rdb->rdb_port->releaseObject(statement->rsr_id); for (RSR* p = &rdb->rdb_sql_requests; *p; p = &(*p)->rsr_next) { @@ -6471,7 +6424,7 @@ * **************************************/ RDB rdb = transaction->rtr_rdb; - SET_OBJECT(rdb, NULL, transaction->rtr_id); + rdb->rdb_port->releaseObject(transaction->rtr_id); while (transaction->rtr_blobs) release_blob(transaction->rtr_blobs); @@ -6484,7 +6437,7 @@ } } - ALLR_free(transaction); + delete transaction; } @@ -6522,9 +6475,9 @@ #ifdef SCROLLABLE_CURSORS static REM_MSG scroll_cache( ISC_STATUS * user_status, - rrq* request, + Rrq* request, rem_port* port, - rrq::rrq_repeat * tail, + Rrq::rrq_repeat * tail, USHORT * direction, ULONG * offset) { /************************************** @@ -6564,16 +6517,16 @@ for, save the last direction asked for by the next layer above */ if (*direction == blr_continue) { - if (tail->rrq_flags & RRQ_last_backward) + if (tail->rrq_flags & Rrq::LAST_BACKWARD) *direction = blr_backward; else *direction = blr_forward; } if (*direction == blr_forward || *direction == blr_bof_forward) - tail->rrq_flags &= ~RRQ_last_backward; + tail->rrq_flags &= ~Rrq::LAST_BACKWARD; else - tail->rrq_flags |= RRQ_last_backward; + tail->rrq_flags |= Rrq::LAST_BACKWARD; /* set to the last message returned to the higher level; if none, set to the first message in cache */ @@ -6586,8 +6539,8 @@ forward one by positioning to the first record, so decrement the offset by one */ if (*offset && - ((*direction == blr_forward) && !(tail->rrq_flags & RRQ_backward)) - || ((*direction == blr_backward) && (tail->rrq_flags & RRQ_backward))) + ((*direction == blr_forward) && !(tail->rrq_flags & Rrq::BACKWARD)) + || ((*direction == blr_backward) && (tail->rrq_flags & Rrq::BACKWARD))) { (*offset)--; } @@ -6597,8 +6550,8 @@ (or vice versa), the cache is unusable. */ if ( - (*direction == blr_bof_forward && (tail->rrq_flags & RRQ_absolute_backward)) - || (*direction == blr_eof_backward && !(tail->rrq_flags & RRQ_absolute_backward))) + (*direction == blr_bof_forward && (tail->rrq_flags & Rrq::ABSOLUTE_BACKWARD)) + || (*direction == blr_eof_backward && !(tail->rrq_flags & Rrq::ABSOLUTE_BACKWARD))) { return dump_cache(port, user_status, tail); } @@ -6616,7 +6569,7 @@ /* if the cache was formed in the backward direction, see if there are any packets pending which might contain the record */ - if ((tail->rrq_flags & RRQ_backward) + if ((tail->rrq_flags & Rrq::BACKWARD) && (tail->rrq_rows_pending > 0)) { tail->rrq_message = message; @@ -6661,8 +6614,8 @@ { if (tail->rrq_rows_pending > 0) { - if (((*direction == blr_forward) && !(tail->rrq_flags & RRQ_backward)) || - ((*direction == blr_backward) && (tail->rrq_flags & RRQ_backward))) + if (((*direction == blr_forward) && !(tail->rrq_flags & Rrq::BACKWARD)) || + ((*direction == blr_backward) && (tail->rrq_flags & Rrq::BACKWARD))) { tail->rrq_message = message; while (!message->msg_address && @@ -6686,8 +6639,8 @@ /* step one record forward or back, depending on whether the cache was initially formed in the forward or backward direction */ - if (((*direction == blr_forward) && !(tail->rrq_flags & RRQ_backward)) || - ((*direction == blr_backward) && (tail->rrq_flags & RRQ_backward))) + if (((*direction == blr_forward) && !(tail->rrq_flags & Rrq::BACKWAR... [truncated message content] |