From: Adriano d. S. F. <asf...@us...> - 2009-06-08 21:49:07
|
Build Version : T2.5.0.24164 Firebird 2.5 Beta 1 (writeBuildNum.sh,v 1.24327 2009/06/08 21:46:29 asfernandes ) Update of /cvsroot/firebird/firebird2/src/remote In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28677/src/remote Modified Files: Tag: B2_5_ExtEngines inet.cpp inet_server.cpp interface.cpp merge.cpp merge_proto.h parser.cpp protocol.cpp remote.cpp remote_def.h server.cpp xdr.cpp xnet.cpp xnet.h xnet_proto.h Log Message: Sync. with HEAD Index: inet.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/inet.cpp,v retrieving revision 1.202.2.9 retrieving revision 1.202.2.10 diff -b -U3 -r1.202.2.9 -r1.202.2.10 --- inet.cpp 20 Apr 2009 22:21:17 -0000 1.202.2.9 +++ inet.cpp 8 Jun 2009 21:46:27 -0000 1.202.2.10 @@ -88,6 +88,9 @@ #include <netdb.h> #include <arpa/inet.h> #include <sys/wait.h> +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif #endif // !WIN_NT const int INET_RETRY_CALL = 5; @@ -276,24 +279,24 @@ const p_cnct::p_cnct_repeat* pSource, size_t nEntries); -static int inet_destroy(XDR *); +static int inet_destroy(XDR*); static void inet_gen_error(rem_port*, const Firebird::Arg::StatusVector& v); -static bool_t inet_getbytes(XDR *, SCHAR *, u_int); -static bool_t inet_getlong(XDR *, SLONG *); -static u_int inet_getpostn(XDR *); -static caddr_t inet_inline(XDR *, u_int); +static bool_t inet_getbytes(XDR*, SCHAR *, u_int); +static bool_t inet_getlong(XDR*, SLONG *); +static u_int inet_getpostn(XDR*); +static caddr_t inet_inline(XDR*, u_int); static void inet_error(rem_port*, const TEXT*, ISC_STATUS, int); static bool_t inet_putlong(XDR*, const SLONG*); static bool_t inet_putbytes(XDR*, const SCHAR*, u_int); -static bool_t inet_read(XDR *); -static bool_t inet_setpostn(XDR *, u_int); +static bool_t inet_read(XDR*); +static bool_t inet_setpostn(XDR*, u_int); static rem_port* inet_try_connect( PACKET*, Rdb*, const Firebird::PathName&, const TEXT*, ISC_STATUS*, Firebird::ClumpletReader&); -static bool_t inet_write(XDR *, int); +static bool_t inet_write(XDR*); //, int); #ifdef DEBUG static void packet_print(const TEXT*, const UCHAR*, int, ULONG); @@ -310,8 +313,7 @@ static int send_full(rem_port*, PACKET *); static int send_partial(rem_port*, PACKET *); -static void unhook_port(rem_port*, rem_port*); -static int xdrinet_create(XDR *, rem_port*, UCHAR *, USHORT, enum xdr_op); +static int xdrinet_create(XDR*, rem_port*, UCHAR *, USHORT, enum xdr_op); static bool setNoNagleOption(rem_port*); static FPTR_INT tryStopMainThread = 0; @@ -579,7 +581,7 @@ } #endif - rem_port* port = alloc_port(0); + rem_port* const port = alloc_port(NULL); port->port_status_vector = status_vector; REMOTE_get_timeout_params(port, dpb); status_vector[0] = isc_arg_gds; @@ -589,7 +591,8 @@ Firebird::string host; Firebird::string protocol; - if (name) { + if (name) + { host = name; const size_t pos = host.find("/"); if (pos != Firebird::string::npos) { @@ -606,7 +609,8 @@ host = port->port_host->str_data; } - if (protocol.isEmpty()) { + if (protocol.isEmpty()) + { const unsigned short port2 = Config::getRemoteServicePort(); if (port2) { protocol.printf("%hu", port2); @@ -776,6 +780,12 @@ lingerInfo.l_onoff = 0; lingerInfo.l_linger = 0; +#ifndef WIN_NT + // dimitr: on Windows, lack of SO_REUSEADDR works the same way as it was specified on POSIX, + // i.e. it allows binding to a port in a TIME_WAIT/FIN_WAIT state. If this option + // is turned on explicitly, then a port can be re-bound regardless of its state, + // e.g. while it's listening. This is surely not what we want. + int optval = TRUE; n = setsockopt((SOCKET) port->port_handle, SOL_SOCKET, SO_REUSEADDR, (SCHAR*) &optval, sizeof(optval)); @@ -784,6 +794,7 @@ disconnect(port); return NULL; } +#endif // Get any values for SO_LINGER so that they can be reset during // disconnect. SO_LINGER should be set by default on the socket @@ -817,11 +828,12 @@ // On Linux platform, when the server dies the system holds a port // for some time. - if (INET_ERRNO == INET_ADDR_IN_USE) { + if (INET_ERRNO == INET_ADDR_IN_USE) + { for (int retry = 0; retry < INET_RETRY_CALL; retry++) { sleep(10); n = bind((SOCKET) port->port_handle, (struct sockaddr *) &address, sizeof(address)); - if (n == 0) + if (n == 0 || INET_ERRNO != INET_ADDR_IN_USE) break; } } @@ -842,7 +854,8 @@ inet_ports->registerPort(port); - if (flag & SRVR_multi_client) { + if (flag & SRVR_multi_client) + { // Prevent the generation of dummy keepalive packets on the connect port. port->port_dummy_packet_interval = 0; @@ -857,7 +870,8 @@ socklen_t l = sizeof(address); SOCKET s = accept((SOCKET) port->port_handle, (struct sockaddr*) &address, &l); const int inetErrNo = INET_ERRNO; - if (s == INVALID_SOCKET) { + if (s == INVALID_SOCKET) + { if (!INET_shutting_down) { inet_error(port, "accept", isc_net_connect_err, inetErrNo); @@ -928,7 +942,7 @@ * a port block. * **************************************/ - rem_port* port = alloc_port(0); + rem_port* const port = alloc_port(NULL); port->port_status_vector = status_vector; status_vector[0] = isc_arg_gds; status_vector[1] = 0; @@ -966,7 +980,7 @@ * **************************************/ int n = 0; - rem_port* port = alloc_port(0); + rem_port* const port = alloc_port(NULL); port->port_flags |= PORT_server; port->port_server_flags |= SRVR_server; port->port_handle = (HANDLE) sock; @@ -1039,7 +1053,7 @@ case CNCT_group: { - int length = id.getClumpLength(); + const int length = id.getClumpLength(); if (length != 0) { eff_gid = 0; memcpy(&eff_gid, id.getBytes(), length); @@ -1108,7 +1122,8 @@ memset(&address, 0, sizeof(address)); int status = getpeername((SOCKET) port->port_handle, (struct sockaddr *) &address, &l); - if (status == 0) { + if (status == 0) + { Firebird::string addr_str; const UCHAR* ip = (UCHAR*) &address.sin_addr; addr_str.printf( @@ -1124,7 +1139,7 @@ } -static rem_port* alloc_port( rem_port* parent) +static rem_port* alloc_port(rem_port* const parent) { /************************************** * @@ -1177,7 +1192,7 @@ } } - rem_port* port = new rem_port(rem_port::INET, INET_remote_buffer * 2); + rem_port* const port = new rem_port(rem_port::INET, INET_remote_buffer * 2); REMOTE_get_timeout_params(port, 0); TEXT buffer[BUFFER_SMALL]; @@ -1230,29 +1245,65 @@ * **************************************/ struct sockaddr_in address; - socklen_t l = sizeof(address); // If this is a server, we're got an auxiliary connection. Accept it if (port->port_server_flags) { + struct timeval timeout; + timeout.tv_sec = port->port_connect_timeout; + timeout.tv_usec = 0; - SOCKET n = accept(port->port_channel, (struct sockaddr*) &address, &l); - const int inetErrNo = INET_ERRNO; + fd_set slct_fdset; + FD_ZERO(&slct_fdset); + FD_SET(port->port_channel, &slct_fdset); + + int inetErrNo = 0; + + while (true) + { + const int count = +#ifdef WIN_NT + select(FD_SETSIZE, &slct_fdset, NULL, NULL, &timeout); +#else + select((SOCKET) port->port_channel + 1, &slct_fdset, NULL, NULL, &timeout); +#endif + inetErrNo = INET_ERRNO; + + if (count != -1 || !INTERRUPT_ERROR(inetErrNo)) + { + if (count == 1) + { + break; + } + else + { + const ISC_STATUS error_code = + (count == 0) ? isc_net_event_connect_timeout : isc_net_event_connect_err; + inet_error(port, "select", error_code, inetErrNo); + SOCLOSE(port->port_channel); + return NULL; + } + } + } + + const SOCKET n = accept(port->port_channel, (struct sockaddr*) &address, &l); + inetErrNo = INET_ERRNO; if (n == INVALID_SOCKET) { inet_error(port, "accept", isc_net_event_connect_err, inetErrNo); SOCLOSE(port->port_channel); return NULL; } + SOCLOSE(port->port_channel); port->port_handle = (HANDLE) n; port->port_flags |= PORT_async; return port; } - rem_port* new_port = alloc_port(port->port_parent); + rem_port* const new_port = alloc_port(port->port_parent); port->port_async = new_port; new_port->port_dummy_packet_interval = port->port_dummy_packet_interval; new_port->port_dummy_timeout = new_port->port_dummy_packet_interval; @@ -1333,13 +1384,18 @@ return NULL; } - int optval = TRUE; - int ret = setsockopt(n, SOL_SOCKET, SO_REUSEADDR, (SCHAR*) &optval, sizeof(optval)); +#ifndef WIN_NT + // dimitr: on Windows, lack of SO_REUSEADDR works the same way as it was specified on POSIX, + // i.e. it allows binding to a port in a TIME_WAIT/FIN_WAIT state. If this option + // is turned on explicitly, then a port can be re-bound regardless of its state, + // e.g. while it's listening. This is surely not what we want. - if (ret == -1) { + int optval = TRUE; + if (setsockopt(n, SOL_SOCKET, SO_REUSEADDR, (SCHAR*) &optval, sizeof(optval)) < 0) { inet_error(port, "setsockopt REUSE", isc_net_event_listen_err, INET_ERRNO); return NULL; } +#endif if (bind(n, (struct sockaddr *) &address, sizeof(address)) < 0) { inet_error(port, "bind", isc_net_event_listen_err, INET_ERRNO); @@ -1358,7 +1414,7 @@ return NULL; } - rem_port* new_port = alloc_port(port->port_parent); + rem_port* const new_port = alloc_port(port->port_parent); port->port_async = new_port; new_port->port_dummy_packet_interval = port->port_dummy_packet_interval; new_port->port_dummy_timeout = new_port->port_dummy_packet_interval; @@ -1434,7 +1490,7 @@ } #endif // !defined(WIN_NT) -static void disconnect( rem_port* port) +static void disconnect(rem_port* const port) { /************************************** * @@ -1475,7 +1531,6 @@ #endif // WIN_NT - // If this is a sub-port, unlink it from it's parent Firebird::MutexLockGuard guard(port_mutex); port->port_state = rem_port::DISCONNECTED; @@ -1484,10 +1539,8 @@ port->port_async = NULL; } - rem_port* parent = port->port_parent; - if (parent != NULL) { - unhook_port(port, parent); - } + // If this is a sub-port, unlink it from its parent + port->unlinkParent(); inet_ports->unRegisterPort(port); @@ -1498,7 +1551,8 @@ port->release(); #ifdef DEBUG - if (INET_trace & TRACE_summary) { + if (INET_trace & TRACE_summary) + { fprintf(stdout, "INET_count_send = %lu packets\n", INET_count_send); fprintf(stdout, "INET_bytes_send = %lu bytes\n", INET_bytes_send); fprintf(stdout, "INET_count_recv = %lu packets\n", INET_count_recv); @@ -1551,7 +1605,7 @@ } -static int cleanup_ports(const int, const int, void* arg) +static int cleanup_ports(const int, const int, void* /*arg*/) { /************************************** * @@ -1794,7 +1848,8 @@ // retry the operation a few times. // NOTE: This still does not guarantee success, but helps. - if ((!host) && (H_ERRNO == INET_RETRY_ERRNO)) { + if ((!host) && (H_ERRNO == INET_RETRY_ERRNO)) + { for (int retry = 0; retry < INET_RETRY_CALL; retry++) { if ( (host = gethostbyname(name)) ) break; @@ -1971,7 +2026,7 @@ **************************************/ struct sockaddr_in address; - rem_port* port = alloc_port(main_port); + rem_port* const port = alloc_port(main_port); socklen_t l = sizeof(address); inet_ports->registerPort(port); @@ -2236,7 +2291,7 @@ return FALSE; #ifdef DEBUG - { + { // scope static ULONG op_sent_count = 0; op_sent_count++; if (INET_trace & TRACE_operations) { @@ -2245,10 +2300,10 @@ op_sent_count, packet->p_operation); fflush(stdout); } - } + } // end scope #endif - return inet_write(&port->port_send, TRUE); + return inet_write(&port->port_send /*, TRUE*/); } static int send_partial( rem_port* port, PACKET * packet) @@ -2265,7 +2320,7 @@ **************************************/ #ifdef DEBUG - { + { // scope static ULONG op_sentp_count = 0; op_sentp_count++; if (INET_trace & TRACE_operations) { @@ -2274,7 +2329,7 @@ op_sentp_count, packet->p_operation); fflush(stdout); } - } + } // end scope #endif return xdr_protocol(&port->port_send, packet); @@ -2321,7 +2376,7 @@ } #endif -static XDR_INT inet_destroy( XDR* xdrs) +static XDR_INT inet_destroy( XDR*) { /************************************** * @@ -2367,7 +2422,7 @@ } -static bool_t inet_getbytes( XDR * xdrs, SCHAR * buff, u_int count) +static bool_t inet_getbytes( XDR* xdrs, SCHAR* buff, u_int count) { /************************************** * @@ -2420,7 +2475,8 @@ if (!bytecount) return TRUE; - if (xdrs->x_handy >= bytecount) { + if (xdrs->x_handy >= bytecount) + { xdrs->x_handy -= bytecount; while (bytecount--) *buff++ = *xdrs->x_private++; @@ -2428,7 +2484,8 @@ return TRUE; } - while (--bytecount >= 0) { + while (--bytecount >= 0) + { if (!xdrs->x_handy && !inet_read(xdrs)) return FALSE; *buff++ = *xdrs->x_private++; @@ -2439,7 +2496,7 @@ } -static bool_t inet_getlong( XDR * xdrs, SLONG * lp) +static bool_t inet_getlong( XDR* xdrs, SLONG* lp) { /************************************** * @@ -2462,7 +2519,7 @@ return TRUE; } -static u_int inet_getpostn( XDR * xdrs) +static u_int inet_getpostn( XDR* xdrs) { /************************************** * @@ -2497,8 +2554,7 @@ return xdrs->x_base + bytecount; } -static void inet_error(rem_port* port, - const TEXT* function, ISC_STATUS operation, int status) +static void inet_error(rem_port* port, const TEXT* function, ISC_STATUS operation, int status) { /************************************** * @@ -2512,14 +2568,16 @@ * to format the status vector if any. * **************************************/ - if (status) { + if (status) + { inet_gen_error(port, Arg::Gds(isc_network_error) << Arg::Str(port->port_connection->str_data) << Arg::Gds(operation) << SYS_ERR(status)); gds__log("INET/inet_error: %s errno = %d", function, status); } - else { + else + { // No status value, just format the basic arguments. inet_gen_error(port, Arg::Gds(isc_network_error) << Arg::Str(port->port_connection->str_data) << @@ -2562,7 +2620,7 @@ xdrs->x_handy = 0; } - if (!inet_write(xdrs, 0)) + if (!inet_write(xdrs /*, 0*/)) return FALSE; } @@ -2572,7 +2630,8 @@ if (!bytecount) return TRUE; - if (xdrs->x_handy >= bytecount) { + if (xdrs->x_handy >= bytecount) + { xdrs->x_handy -= bytecount; while (bytecount--) *xdrs->x_private++ = *buff++; @@ -2580,8 +2639,9 @@ return TRUE; } - while (--bytecount >= 0) { - if (xdrs->x_handy <= 0 && !inet_write(xdrs, 0)) + while (--bytecount >= 0) + { + if (xdrs->x_handy <= 0 && !inet_write(xdrs /*, 0*/)) return FALSE; --xdrs->x_handy; *xdrs->x_private++ = *buff++; @@ -2607,7 +2667,7 @@ return (*xdrs->x_ops->x_putbytes) (xdrs, reinterpret_cast<const char*>(&l), 4); } -static bool_t inet_read( XDR * xdrs) +static bool_t inet_read( XDR* xdrs) { /************************************** * @@ -2655,7 +2715,7 @@ return TRUE; } -static bool_t inet_setpostn( XDR * xdrs, u_int bytecount) +static bool_t inet_setpostn( XDR* xdrs, u_int bytecount) { /************************************** * @@ -2718,7 +2778,8 @@ rdb->rdb_port = port; port->port_context = rdb; - if (!port->receive(packet)) { + if (!port->receive(packet)) + { inet_error(port, "receive in try_connect", isc_net_connect_err, INET_ERRNO); disconnect(port); delete rdb; @@ -2728,7 +2789,7 @@ return port; } -static bool_t inet_write( XDR * xdrs, bool_t end_flag) +static bool_t inet_write( XDR* xdrs /*, bool_t end_flag*/) { /************************************** * @@ -2737,7 +2798,8 @@ ************************************** * * Functional description - * Write a buffer full of data. If the end_flag isn't set, indicate + * Write a buffer full of data. + * Obsolete: If the end_flag isn't set, indicate * that the buffer is a fragment, and reset the XDR for another buffer * load. * @@ -2819,8 +2881,7 @@ } #ifdef DEBUG -static void packet_print(const TEXT* string, - const UCHAR* packet, int length, ULONG counter) +static void packet_print(const TEXT* string, const UCHAR* packet, int length, ULONG counter) { /************************************** * @@ -2989,7 +3050,7 @@ } #ifdef DEBUG - { + { // scope INET_count_recv++; INET_bytes_recv += n; if (INET_trace & TRACE_packets) @@ -3000,7 +3061,7 @@ inet_error(port, "simulated error - read", isc_net_read_err, 0); return false; } - } + } // end scope #endif *length = n; @@ -3127,7 +3188,7 @@ } #ifdef DEBUG - { + { // scope INET_count_send++; INET_bytes_send += buffer_length; if (INET_trace & TRACE_packets) @@ -3138,37 +3199,12 @@ inet_error(port, "simulated error - send", isc_net_write_err, 0); return false; } - } + } // end scope #endif return true; } -static void unhook_port( rem_port* port, rem_port* parent) -{ -/************************************** - * - * u n h o o k _ p a r e n t - * - ************************************** - * - * Functional description - * Disconnect a port from its parent - * This must be done under port_mutex control. - * - **************************************/ - - for (rem_port** ptr = &parent->port_clients; *ptr; ptr = &(*ptr)->port_next) { - if (*ptr == port) { - *ptr = port->port_next; - if (ptr == &parent->port_clients) { - parent->port_next = *ptr; - } - break; - } - } -} - static bool setNoNagleOption(rem_port* port) { /************************************** Index: inet_server.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/inet_server.cpp,v retrieving revision 1.74.2.6 retrieving revision 1.74.2.7 diff -b -U3 -r1.74.2.6 -r1.74.2.7 --- inet_server.cpp 20 Apr 2009 22:21:17 -0000 1.74.2.6 +++ inet_server.cpp 8 Jun 2009 21:46:27 -0000 1.74.2.7 @@ -46,11 +46,11 @@ #include <sys/types.h> #endif -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> @@ -61,7 +61,7 @@ #include <unistd.h> #endif -#if HAVE_SYS_WAIT_H +#ifdef HAVE_SYS_WAIT_H # include <sys/wait.h> #endif @@ -371,7 +371,8 @@ } } // end scope block } - else { + else + { port = INET_server(channel); if (!port) { fprintf(stderr, "fbserver: Unable to start INET_server\n"); Index: interface.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/interface.cpp,v retrieving revision 1.160.2.8 retrieving revision 1.160.2.9 diff -b -U3 -r1.160.2.8 -r1.160.2.9 --- interface.cpp 20 Apr 2009 22:21:17 -0000 1.160.2.8 +++ interface.cpp 8 Jun 2009 21:46:27 -0000 1.160.2.9 @@ -86,8 +86,6 @@ #define sleep(seconds) Sleep ((seconds) * 1000) #endif // WIN_NT -//const int MAX_USER_LENGTH = 33; -//const int MAX_OTHER_PARAMS = 1 + 1 + sizeof(((rem_port*)NULL)->port_dummy_packet_interval); using namespace Firebird; @@ -399,7 +397,8 @@ * **************************************/ Rbl* blob = *blob_handle; - if (!blob) { + if (!blob) + { if (user_status) { *user_status++ = isc_arg_gds; *user_status++ = FB_SUCCESS; @@ -915,7 +914,7 @@ MERGE_database_info(temp_buffer, buffer, buffer_length, IMPLEMENTATION, 3, 1, reinterpret_cast<const UCHAR*>(version.c_str()), - reinterpret_cast<const UCHAR*>(port->port_host->str_data), 0); + reinterpret_cast<const UCHAR*>(port->port_host->str_data)); } } catch (const Exception& ex) @@ -1226,7 +1225,7 @@ USHORT in_blr_length, const UCHAR* in_blr, USHORT in_msg_type, - USHORT in_msg_length, + USHORT /*in_msg_length*/, UCHAR* in_msg, USHORT out_blr_length, UCHAR* out_blr, @@ -1284,7 +1283,8 @@ // Parse the blr describing the message, if there is any. - if (in_blr_length) { + if (in_blr_length) + { RMessage* message = PARSE_messages(in_blr, in_blr_length); if (message != (RMessage*) - 1) { statement->rsr_bind_format = (rem_fmt*) message->msg_address; @@ -1398,7 +1398,8 @@ if (user_status[1]) return user_status[1]; - if (transaction && !packet->p_resp.p_resp_object) { + if (transaction && !packet->p_resp.p_resp_object) + { REMOTE_cleanup_transaction(transaction); release_transaction(transaction); *rtr_handle = NULL; @@ -1734,7 +1735,8 @@ } - if (!statement->rsr_buffer) { + if (!statement->rsr_buffer) + { statement->rsr_buffer = new RMessage(0); statement->rsr_message = statement->rsr_buffer; statement->rsr_message->msg_next = statement->rsr_message; @@ -1947,7 +1949,8 @@ release_sql_request(statement); *stmt_handle = NULL; } - else { + else + { statement->rsr_flags.clear(Rsr::FETCHED); statement->rsr_rtr = NULL; @@ -1987,7 +1990,8 @@ release_sql_request(statement); *stmt_handle = NULL; } - else { + else + { statement->rsr_flags.clear(Rsr::FETCHED); statement->rsr_rtr = NULL; @@ -2011,7 +2015,7 @@ USHORT blr_length, const UCHAR* blr, USHORT msg_type, - USHORT msg_length, + USHORT /*msg_length*/, UCHAR* msg) { /************************************** @@ -2050,7 +2054,8 @@ // Parse the blr describing the message, if there is any. - if (blr_length) { + if (blr_length) + { RMessage* message = PARSE_messages(blr, blr_length); if (message != (RMessage*) - 1) { statement->rsr_bind_format = (rem_fmt*) message->msg_address; @@ -2080,7 +2085,8 @@ PACKET* packet = &rdb->rdb_packet; - if (statement->rsr_flags.test(Rsr::LAZY)) { + if (statement->rsr_flags.test(Rsr::LAZY)) + { packet->p_operation = op_allocate_statement; packet->p_rlse.p_rlse_object = rdb->rdb_id; @@ -2191,7 +2197,8 @@ PACKET* packet = &rdb->rdb_packet; - if (statement->rsr_flags.test(Rsr::LAZY)) { + if (statement->rsr_flags.test(Rsr::LAZY)) + { packet->p_operation = op_allocate_statement; packet->p_rlse.p_rlse_object = rdb->rdb_id; @@ -3755,10 +3762,10 @@ } -ISC_STATUS GDS_SEND(ISC_STATUS * user_status, +ISC_STATUS GDS_SEND(ISC_STATUS* user_status, Rrq** req_handle, USHORT msg_type, - USHORT msg_length, + USHORT /*msg_length*/, const UCHAR* msg, SSHORT level) { @@ -3947,7 +3954,7 @@ ISC_STATUS GDS_SERVICE_QUERY(ISC_STATUS* user_status, Rdb** svc_handle, - ULONG* reserved, + ULONG* /*reserved*/, USHORT item_length, const UCHAR* items, USHORT recv_item_length, @@ -4004,7 +4011,7 @@ ISC_STATUS GDS_SERVICE_START(ISC_STATUS* user_status, Rdb** svc_handle, - ULONG* reserved, + ULONG* /*reserved*/, USHORT item_length, const UCHAR* items) { @@ -4057,7 +4064,7 @@ Rrq** req_handle, Rtr** rtr_handle, USHORT msg_type, - USHORT msg_length, + USHORT /*msg_length*/, UCHAR* msg, SSHORT level) { @@ -4087,7 +4094,8 @@ try { - if ((*rtr_handle)->rtr_rdb != rdb) { + if ((*rtr_handle)->rtr_rdb != rdb) + { user_status[0] = isc_arg_gds; user_status[1] = isc_trareqmis; user_status[2] = isc_arg_end; @@ -4171,7 +4179,8 @@ try { - if ((*rtr_handle)->rtr_rdb != rdb) { + if ((*rtr_handle)->rtr_rdb != rdb) + { user_status[0] = isc_arg_gds; user_status[1] = isc_trareqmis; user_status[2] = isc_arg_end; @@ -4217,7 +4226,7 @@ ISC_STATUS GDS_START_TRANSACTION(ISC_STATUS* user_status, FB_API_HANDLE public_handle, Rtr** rtr_handle, - SSHORT count, + SSHORT /*count*/, Rdb** db_handle, SSHORT tpb_length, const UCHAR* tpb) @@ -4277,7 +4286,7 @@ UCHAR* blr, USHORT in_msg_length, UCHAR* in_msg, - USHORT out_msg_length, + USHORT /*out_msg_length*/, UCHAR* out_msg) { /************************************** @@ -4312,7 +4321,8 @@ procedure = port->port_rpr = new Rpr; } - if ((*rtr_handle)->rtr_rdb != rdb) { + if ((*rtr_handle)->rtr_rdb != rdb) + { user_status[0] = isc_arg_gds; user_status[1] = isc_trareqmis; user_status[2] = isc_arg_end; @@ -4612,7 +4622,7 @@ #if defined(WIN_NT) if (ISC_analyze_pclan(file_name, node_name)) { - return WNET_analyze(file_name, status_vector, node_name.c_str(), user_string, uv_flag); + return WNET_analyze(file_name, status_vector, node_name.c_str(), /*user_string,*/ uv_flag); } #endif @@ -4645,8 +4655,7 @@ // retry in case multiclient inet server not forked yet sleep(2); - port = - INET_analyze(file_name, status_vector, + port = INET_analyze(file_name, status_vector, node_name.c_str(), user_string, uv_flag, dpb); } } @@ -4661,7 +4670,7 @@ if (!port && node_name.isEmpty()) { - return XNET_analyze(file_name, status_vector, node_name.c_str(), user_string, uv_flag); + return XNET_analyze(file_name, status_vector, /*node_name.c_str(), user_string,*/ uv_flag); } #endif // USE_XNET @@ -4674,7 +4683,7 @@ { file_name.insert(0, "\\\\.\\"); if (ISC_analyze_pclan(file_name, node_name)) - return WNET_analyze(file_name, status_vector, node_name.c_str(), user_string, uv_flag); + return WNET_analyze(file_name, status_vector, node_name.c_str(), /*user_string,*/ uv_flag); } #endif // WIN_NT @@ -4732,7 +4741,7 @@ #if defined(WIN_NT) if (ISC_analyze_pclan(service_name, node_name)) { - return WNET_analyze(service_name, status_vector, node_name.c_str(), user_string, uv_flag); + return WNET_analyze(service_name, status_vector, node_name.c_str(), /*user_string,*/ uv_flag); } #endif if (!port) { @@ -4748,14 +4757,15 @@ // interprocess server if (!port && node_name.isEmpty()) { - port = XNET_analyze(service_name, status_vector, node_name.c_str(), user_string, uv_flag); + port = XNET_analyze(service_name, status_vector, /*node_name.c_str(), user_string,*/ uv_flag); } #endif #ifdef SUPERCLIENT #ifdef UNIX - if (!port && node_name.isEmpty()) { + if (!port && node_name.isEmpty()) + { service_name.insert(0, "localhost:"); if (ISC_analyze_tcp(service_name, node_name)) { @@ -5309,7 +5319,8 @@ return NULL; RMessage* message = tail->rrq_message; - while (true) { + while (true) + { message->msg_address = NULL; message = message->msg_next; if (message == tail->rrq_message) @@ -5366,7 +5377,7 @@ server_death(port); break; } - } + } // end scope // If the packet was an event, we handle it @@ -5414,7 +5425,7 @@ USHORT blr_length, UCHAR* blr, USHORT msg_type, - USHORT msg_length, + USHORT /*msg_length*/, UCHAR* msg) { /************************************** @@ -5507,7 +5518,8 @@ * Analyze and prepare dpb for attachment to remote server. * **************************************/ - if (!Config::getRedirection()) { + if (!Config::getRedirection()) + { if (dpb.find(par.address_path)) { status_exception::raise(Arg::Gds(isc_unavailable)); } Index: merge.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/merge.cpp,v retrieving revision 1.24.6.2 retrieving revision 1.24.6.3 diff -b -U3 -r1.24.6.2 -r1.24.6.3 --- merge.cpp 20 Apr 2009 22:21:17 -0000 1.24.6.2 +++ merge.cpp 8 Jun 2009 21:46:27 -0000 1.24.6.3 @@ -49,8 +49,8 @@ USHORT class_, USHORT base_level, const UCHAR* version, - const UCHAR* id, - ULONG mask) + const UCHAR* id) + //ULONG mask Was always zero { /************************************** * Index: merge_proto.h =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/merge_proto.h,v retrieving revision 1.5 retrieving revision 1.5.28.1 diff -b -U3 -r1.5 -r1.5.28.1 --- merge_proto.h 6 Nov 2003 03:03:16 -0000 1.5 +++ merge_proto.h 8 Jun 2009 21:46:27 -0000 1.5.28.1 @@ -25,7 +25,7 @@ #define REMOTE_MERGE_PROTO_H USHORT MERGE_database_info(const UCHAR*, UCHAR*, USHORT, USHORT, - USHORT, USHORT, const UCHAR*, const UCHAR*, ULONG); + USHORT, USHORT, const UCHAR*, const UCHAR*); //, ULONG); #endif // REMOTE_MERGE_PROTO_H Index: parser.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/parser.cpp,v retrieving revision 1.19.2.3 retrieving revision 1.19.2.4 diff -b -U3 -r1.19.2.3 -r1.19.2.4 --- parser.cpp 20 Apr 2009 22:21:17 -0000 1.19.2.3 +++ parser.cpp 8 Jun 2009 21:46:27 -0000 1.19.2.4 @@ -36,6 +36,8 @@ #endif +static RMessage* parse_error(rem_fmt* format, RMessage* mesage); + RMessage* PARSE_messages(const UCHAR* blr, USHORT blr_length) { @@ -51,20 +53,28 @@ * messages found. If an error occurs, return -1; * **************************************/ - RMessage* next; + + if (blr_length < 2) + return (RMessage*) -1; + blr_length -= 2; const SSHORT version = *blr++; - if ((version != blr_version4) && (version != blr_version5)) - return (RMessage*) - 1; + if (version != blr_version4 && version != blr_version5) + return (RMessage*) -1; if (*blr++ != blr_begin) return 0; + RMessage* message = NULL; USHORT net_length = 0; while (*blr++ == blr_message) { + if (blr_length < 4) + return parse_error(0, message); + blr_length -= 4; + const USHORT msg_number = *blr++; USHORT count = *blr++; count += (*blr++) << 8; @@ -76,10 +86,16 @@ USHORT offset = 0; for (dsc* desc = format->fmt_desc.begin(); count; --count, ++desc) { + if (blr_length-- == 0) + return parse_error(format, message); + USHORT align = 4; switch (*blr++) { case blr_text: + if (blr_length < 2) + return parse_error(format, message); + blr_length -= 2; desc->dsc_dtype = dtype_text; desc->dsc_length = *blr++; desc->dsc_length += (*blr++) << 8; @@ -87,6 +103,9 @@ break; case blr_varying: + if (blr_length < 2) + return parse_error(format, message); + blr_length -= 2; desc->dsc_dtype = dtype_varying; desc->dsc_length = *blr++ + sizeof(SSHORT); desc->dsc_length += (*blr++) << 8; @@ -94,6 +113,9 @@ break; case blr_cstring: + if (blr_length < 2) + return parse_error(format, message); + blr_length -= 2; desc->dsc_dtype = dtype_cstring; desc->dsc_length = *blr++; desc->dsc_length += (*blr++) << 8; @@ -103,6 +125,9 @@ // Parse the tagged blr types correctly case blr_text2: + if (blr_length < 4) + return parse_error(format, message); + blr_length -= 4; desc->dsc_dtype = dtype_text; desc->dsc_scale = *blr++; desc->dsc_scale += (*blr++) << 8; @@ -112,6 +137,9 @@ break; case blr_varying2: + if (blr_length < 4) + return parse_error(format, message); + blr_length -= 4; desc->dsc_dtype = dtype_varying; desc->dsc_scale = *blr++; desc->dsc_scale += (*blr++) << 8; @@ -121,6 +149,9 @@ break; case blr_cstring2: + if (blr_length < 4) + return parse_error(format, message); + blr_length -= 4; desc->dsc_dtype = dtype_cstring; desc->dsc_scale = *blr++; desc->dsc_scale += (*blr++) << 8; @@ -130,6 +161,8 @@ break; case blr_short: + if (blr_length-- == 0) + return parse_error(format, message); desc->dsc_dtype = dtype_short; desc->dsc_length = sizeof(SSHORT); desc->dsc_scale = *blr++; @@ -137,6 +170,8 @@ break; case blr_long: + if (blr_length-- == 0) + return parse_error(format, message); desc->dsc_dtype = dtype_long; desc->dsc_length = sizeof(SLONG); desc->dsc_scale = *blr++; @@ -144,6 +179,8 @@ break; case blr_int64: + if (blr_length-- == 0) + return parse_error(format, message); desc->dsc_dtype = dtype_int64; desc->dsc_length = sizeof(SINT64); desc->dsc_scale = *blr++; @@ -151,6 +188,8 @@ break; case blr_quad: + if (blr_length-- == 0) + return parse_error(format, message); desc->dsc_dtype = dtype_quad; desc->dsc_length = sizeof(SLONG) * 2; desc->dsc_scale = *blr++; @@ -170,17 +209,20 @@ align = type_alignments[dtype_double]; break; -/* this case cannot occur as switch paramater is char and blr_blob - is 261. blob_ids are actually passed around as blr_quad. + // this case cannot occur as switch paramater is char and blr_blob + // is 261. blob_ids are actually passed around as blr_quad. + + //case blr_blob: + // desc->dsc_dtype = dtype_blob; + // desc->dsc_length = sizeof (SLONG) * 2; + // align = type_alignments [dtype_blob]; + // break; - case blr_blob: - desc->dsc_dtype = dtype_blob; - desc->dsc_length = sizeof (SLONG) * 2; - align = type_alignments [dtype_blob]; - break; -*/ case blr_blob2: { + if (blr_length < 4) + return parse_error(format, message); + blr_length -= 4; desc->dsc_dtype = dtype_blob; desc->dsc_length = sizeof(SLONG) * 2; desc->dsc_sub_type = *blr++; @@ -214,13 +256,7 @@ default: fb_assert(FALSE); - delete format; - while (next = message) { - message = message->msg_next; - delete next->msg_address; - delete next; - } - return (RMessage*) - 1; + return parse_error(format, message); } if (desc->dsc_dtype == dtype_varying) net_length += 4 + ((desc->dsc_length - 2 + 3) & ~3); @@ -233,7 +269,7 @@ } format->fmt_length = offset; format->fmt_net_length = net_length; - next = new RMessage(format->fmt_length); + RMessage* next = new RMessage(format->fmt_length); #ifdef DEBUG_REMOTE_MEMORY printf("PARSE_messages allocate message %x\n", next); #endif @@ -247,6 +283,19 @@ } +static RMessage* parse_error(rem_fmt* format, RMessage* message) +{ + delete format; + for (RMessage* next = message; next; next = message) + { + message = message->msg_next; + delete next->msg_address; + delete next; + } + return (RMessage*) -1; +} + + const UCHAR* PARSE_prepare_messages(const UCHAR* blr, USHORT blr_length) { /************************************** Index: protocol.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/protocol.cpp,v retrieving revision 1.62.2.7 retrieving revision 1.62.2.8 diff -b -U3 -r1.62.2.7 -r1.62.2.8 --- protocol.cpp 20 Apr 2009 22:21:17 -0000 1.62.2.7 +++ protocol.cpp 8 Jun 2009 21:46:27 -0000 1.62.2.8 @@ -62,21 +62,21 @@ xdr_debug_memory(xdrs, XDR_DECODE, xdrvar, addr, len); } #else -inline bool_t P_TRUE(XDR* xdrs, PACKET* p) +inline bool_t P_TRUE(XDR*, PACKET*) { return TRUE; } -inline bool_t P_FALSE(XDR* xdrs, PACKET* p) +inline bool_t P_FALSE(XDR*, PACKET*) { return FALSE; } -inline void DEBUG_XDR_PACKET(XDR* xdrs, PACKET* p) +inline void DEBUG_XDR_PACKET(XDR*, PACKET*) { } -inline void DEBUG_XDR_ALLOC(XDR* xdrs, const void* xdrvar, const void* addr, ULONG len) +inline void DEBUG_XDR_ALLOC(XDR*, const void*, const void*, ULONG) { } -inline void DEBUG_XDR_FREE(XDR* xdrs, const void* xdrvar, const void* addr, ULONG len) +inline void DEBUG_XDR_FREE(XDR*, const void*, const void*, ULONG) { } #endif // DEBUG_XDR_MEMORY @@ -103,7 +103,7 @@ static bool_t xdr_message(XDR*, RMessage*, const rem_fmt*); static bool_t xdr_quad(XDR*, struct bid*); static bool_t xdr_request(XDR*, USHORT, USHORT, USHORT); -static bool_t xdr_slice(XDR*, lstring*, USHORT, const UCHAR*); +static bool_t xdr_slice(XDR*, lstring*, /*USHORT,*/ const UCHAR*); static bool_t xdr_status_vector(XDR*, ISC_STATUS*, TEXT * strings[]); static bool_t xdr_sql_blr(XDR*, SLONG, CSTRING*, bool, SQL_STMT_TYPE); static bool_t xdr_sql_message(XDR*, SLONG); @@ -149,7 +149,7 @@ (xdrs->x_handy - xdr_save_size) : (xdr_save_size - xdrs->x_handy))); } #else -inline void DEBUG_PRINTSIZE(XDR* xdrs, P_OP p) +inline void DEBUG_PRINTSIZE(XDR*, P_OP) { } #endif @@ -582,14 +582,14 @@ MAP(xdr_longs, slice->p_slc_parameters); slice_response = &p->p_slr; if (slice_response->p_slr_sdl) { - if (!xdr_slice(xdrs, &slice->p_slc_slice, slice_response->p_slr_sdl_length, + if (!xdr_slice(xdrs, &slice->p_slc_slice, //slice_response->p_slr_sdl_length, slice_response->p_slr_sdl)) { return P_FALSE(xdrs, p); } } else - if (!xdr_slice(xdrs, &slice->p_slc_slice, slice->p_slc_sdl.cstr_length, + if (!xdr_slice(xdrs, &slice->p_slc_slice, //slice->p_slc_sdl.cstr_length, slice->p_slc_sdl.cstr_address)) { return P_FALSE(xdrs, p); @@ -600,7 +600,7 @@ case op_slice: slice_response = &p->p_slr; MAP(xdr_long, reinterpret_cast<SLONG&>(slice_response->p_slr_length)); - if (!xdr_slice (xdrs, &slice_response->p_slr_slice, slice_response->p_slr_sdl_length, + if (!xdr_slice (xdrs, &slice_response->p_slr_slice, //slice_response->p_slr_sdl_length, slice_response->p_slr_sdl)) { return P_FALSE(xdrs, p); @@ -668,7 +668,7 @@ case op_fetch: sqldata = &p->p_sqldata; - MAP(xdr_short,reinterpret_cast<SSHORT&>(sqldata->p_sqldata_statement)); + MAP(xdr_short, reinterpret_cast<SSHORT&>(sqldata->p_sqldata_statement)); xdr_sql_blr(xdrs, (SLONG) sqldata->p_sqldata_statement, &sqldata->p_sqldata_blr, true, TYPE_PREPARED); MAP(xdr_short, reinterpret_cast<SSHORT&>(sqldata->p_sqldata_message_number)); @@ -1336,7 +1336,8 @@ } -static bool_t xdr_slice(XDR* xdrs, lstring* slice, USHORT sdl_length, const UCHAR* sdl) +// Maybe it's better to take sdl_length into account? +static bool_t xdr_slice(XDR* xdrs, lstring* slice, /*USHORT sdl_length,*/ const UCHAR* sdl) { /************************************** * Index: remote.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/remote.cpp,v retrieving revision 1.50.2.8 retrieving revision 1.50.2.9 diff -b -U3 -r1.50.2.8 -r1.50.2.9 --- remote.cpp 20 Apr 2009 22:21:17 -0000 1.50.2.8 +++ remote.cpp 8 Jun 2009 21:46:27 -0000 1.50.2.9 @@ -593,7 +593,7 @@ } -static void cleanup_memory(void* block) +static void cleanup_memory(void* /*block*/) { /************************************** * @@ -618,24 +618,23 @@ void rem_port::linkParent(rem_port* const parent) { fb_assert(parent); + fb_assert(this->port_parent == NULL); - port_parent = parent; - port_next = parent->port_clients; - port_handle = parent->port_handle; - port_server = parent->port_server; - port_server_flags = parent->port_server_flags; + this->port_parent = parent; + this->port_next = parent->port_clients; + this->port_handle = parent->port_handle; + this->port_server = parent->port_server; + this->port_server_flags = parent->port_server_flags; parent->port_clients = parent->port_next = this; } void rem_port::unlinkParent() { - fb_assert(this->port_parent != NULL); - if (this->port_parent == NULL) return; -#if DEV_BUILD +#ifdef DEV_BUILD bool found = false; #endif @@ -652,7 +651,7 @@ this->port_parent->port_next = *ptr; } -#if DEV_BUILD +#ifdef DEV_BUILD found = true; #endif break; Index: remote_def.h =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/remote_def.h,v retrieving revision 1.31.2.3 retrieving revision 1.31.2.4 diff -b -U3 -r1.31.2.3 -r1.31.2.4 --- remote_def.h 20 Apr 2009 22:21:17 -0000 1.31.2.3 +++ remote_def.h 8 Jun 2009 21:46:27 -0000 1.31.2.4 @@ -42,7 +42,7 @@ #include "../remote/protocol.h" -#if defined(sun) +#if defined(__sun) # ifdef sparc const P_ARCH ARCHITECTURE = arch_sun4; #elif (defined i386 || defined AMD64) Index: server.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/server.cpp,v retrieving revision 1.169.2.10 retrieving revision 1.169.2.11 diff -b -U3 -r1.169.2.10 -r1.169.2.11 --- server.cpp 20 Apr 2009 22:21:17 -0000 1.169.2.10 +++ server.cpp 8 Jun 2009 21:46:27 -0000 1.169.2.11 @@ -60,7 +60,7 @@ #ifdef DEBUG #include "gen/iberror.h" #endif -#include "../jrd/os/isc_i_proto.h" +#include "../common/classes/FpeControl.h" #include "../remote/proto_proto.h" // xdr_protocol_overhead() #include "../jrd/scroll_cursors.h" @@ -106,7 +106,7 @@ static bool link_request(rem_port*, server_req_t*); static bool accept_connection(rem_port*, P_CNCT*, PACKET*); -static ISC_STATUS allocate_statement(rem_port*, P_RLSE*, PACKET*); +static ISC_STATUS allocate_statement(rem_port*, /*P_RLSE*,*/ PACKET*); static void append_request_chain(server_req_t*, server_req_t**); static void append_request_next(server_req_t*, server_req_t**); static void attach_database(rem_port*, P_OP, P_ATCH*, PACKET*); @@ -121,7 +121,7 @@ #ifdef NOT_USED_OR_REPLACED static void aux_connect(rem_port*, P_REQ*, PACKET*); #endif -static void aux_request(rem_port*, P_REQ*, PACKET*); +static void aux_request(rem_port*, /*P_REQ*,*/ PACKET*); static ISC_STATUS cancel_events(rem_port*, P_EVENT*, PACKET*); static void addClumplets(Firebird::ClumpletWriter&, const ParametersSet&, const rem_port*); @@ -268,7 +268,7 @@ * **************************************/ - ISC_enter(); // Setup floating point exception handler once and for all. + Firebird::FpeControl::maskAll(); // Setup context pool for main thread Firebird::ContextPoolHolder mainThreadContext(getDefaultMemoryPool()); @@ -672,7 +672,7 @@ } } catch (const Firebird::Exception&) { - // Some kind of unhandled error occured during server setup. In lieu + // Some kind of unhandled error occurred during server setup. In lieu // of anything we CAN do, log something (and we might be so hosed // we can't log anything) and give up. // The likely error here is out-of-memory. @@ -777,7 +777,7 @@ } -static ISC_STATUS allocate_statement( rem_port* port, P_RLSE * allocate, PACKET* send) +static ISC_STATUS allocate_statement( rem_port* port, /*P_RLSE* allocate,*/ PACKET* send) { /************************************** * @@ -1141,7 +1141,7 @@ #endif -static void aux_request( rem_port* port, P_REQ * request, PACKET* send) +static void aux_request( rem_port* port, /*P_REQ* request,*/ PACKET* send) { /************************************** * @@ -1630,7 +1630,7 @@ } -void rem_port::drop_database(P_RLSE* release, PACKET* sendL) +void rem_port::drop_database(P_RLSE* /*release*/, PACKET* sendL) { /************************************** * @@ -1740,7 +1740,7 @@ } -ISC_STATUS rem_port::end_database(P_RLSE * release, PACKET* sendL) +ISC_STATUS rem_port::end_database(P_RLSE* /*release*/, PACKET* sendL) { /************************************** * @@ -2709,8 +2709,7 @@ buffer, stuff->p_info_buffer_length, IMPLEMENTATION, 4, 1, reinterpret_cast<const UCHAR*>(version.c_str()), - reinterpret_cast<const UCHAR*>(this->port_host->str_data), - 0); + reinterpret_cast<const UCHAR*>(this->port_host->str_data)); } break; @@ -3272,7 +3271,7 @@ break; case op_connect_request: - aux_request(port, &receive->p_req, sendL); + aux_request(port, /*&receive->p_req,*/ sendL); break; #ifdef NOT_USED_OR_REPLACED @@ -3294,7 +3293,7 @@ break; case op_allocate_statement: - allocate_statement(port, &receive->p_rlse, sendL); + allocate_statement(port, /*&receive->p_rlse,*/ sendL); break; case op_execute: @@ -4636,7 +4635,7 @@ } -ISC_STATUS rem_port::service_end(P_RLSE * release, PACKET* sendL) +ISC_STATUS rem_port::service_end(P_RLSE* /*release*/, PACKET* sendL) { /************************************** * @@ -4940,7 +4939,7 @@ * **************************************/ - ISC_enter(); // Setup floating point exception handler once and for all. + Firebird::FpeControl::maskAll(); Worker worker; rem_port* port = NULL; @@ -5398,6 +5397,10 @@ { ++m_cntAll; } + else if (!m_cntAll) + { + Firebird::Arg::Gds(isc_no_threads).raise(); + } } } Index: xdr.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/xdr.cpp,v retrieving revision 1.29.2.8 retrieving revision 1.29.2.9 diff -b -U3 -r1.29.2.8 -r1.29.2.9 --- xdr.cpp 20 Apr 2009 22:21:17 -0000 1.29.2.8 +++ xdr.cpp 8 Jun 2009 21:46:27 -0000 1.29.2.9 @@ -34,7 +34,7 @@ #include "../jrd/gds_proto.h" #ifdef BURP -#include "../burp/misc_proto.h" // Was "../burp/misc_pro.h" -Jeevan +#include "../burp/misc_proto.h" inline UCHAR* XDR_ALLOC(ULONG size) { return MISC_alloc_burp(size); @@ -64,10 +64,10 @@ xdr_debug_memory (xdrs, XDR_FREE, xdrvar, addr, (ULONG) len); } #else -inline void DEBUG_XDR_ALLOC(XDR* xdrs, const void* xdrvar, const void* addr, ULONG len) +inline void DEBUG_XDR_ALLOC(XDR*, const void*, const void*, ULONG) { } -inline void DEBUG_XDR_FREE(XDR* xdrs, const void* xdrvar, const void* addr, ULONG len) +inline void DEBUG_XDR_FREE(XDR*, const void*, const void*, ULONG) { } #endif // DEBUG_XDR_MEMORY @@ -784,7 +784,7 @@ } -static XDR_INT mem_destroy(XDR* xdrs) +static XDR_INT mem_destroy(XDR*) { /************************************** * Index: xnet.cpp =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/xnet.cpp,v retrieving revision 1.98.2.8 retrieving revision 1.98.2.9 diff -b -U3 -r1.98.2.8 -r1.98.2.9 --- xnet.cpp 20 Apr 2009 22:21:17 -0000 1.98.2.8 +++ xnet.cpp 8 Jun 2009 21:46:27 -0000 1.98.2.9 @@ -85,7 +85,7 @@ static int xdrxnet_create(XDR *, rem_port*, UCHAR *, USHORT, xdr_op); -static int xnet_destroy(XDR *); +static int xnet_destroy(XDR*); static bool_t xnet_getbytes(XDR *, SCHAR *, u_int); static bool_t xnet_getlong(XDR *, SLONG *); static u_int xnet_getpostn(XDR *); @@ -197,8 +197,8 @@ rem_port* XNET_analyze(const Firebird::PathName& file_name, ISC_STATUS* status_vector, - const TEXT* node_name, - const TEXT* user_string, + //const TEXT* node_name, + //const TEXT* user_string, bool uv_flag) { /************************************** @@ -274,7 +274,7 @@ // If we can't talk to a server, punt. Let somebody else generate an error. - rem_port* port = XNET_connect(node_name, packet, status_vector, 0); + rem_port* port = XNET_connect(/*node_name,*/ packet, status_vector, 0); if (!port) { delete rdb; return NULL; @@ -312,7 +312,7 @@ cnct->p_cnct_versions[i] = protocols_to_try2[i]; } - if (!(port = XNET_connect(node_name, packet, status_vector, 0))) { + if (!(port = XNET_connect(/*node_name,*/ packet, status_vector, 0))) { delete rdb; return NULL; } @@ -349,7 +349,7 @@ cnct->p_cnct_versions[i] = protocols_to_try3[i]; } - if (!(port = XNET_connect(node_name, packet, status_vector, 0))) { + if (!(port = XNET_connect(/*node_name,*/ packet, status_vector, 0))) { delete rdb; return NULL; } @@ -395,7 +395,7 @@ } -rem_port* XNET_connect(const TEXT* name, +rem_port* XNET_connect(//const TEXT* name, PACKET* packet, ISC_STATUS* status_vector, USHORT flag) @@ -646,9 +646,9 @@ static rem_port* alloc_port(rem_port* parent, - UCHAR * send_buffer, + UCHAR* send_buffer, ULONG send_length, - UCHAR * receive_buffer, + UCHAR* receive_buffer, ULONG receive_length) { /************************************** @@ -662,7 +662,7 @@ * and initialize input and output XDR streams. * **************************************/ - rem_port* port = new rem_port(rem_port::XNET, 0); + rem_port* const port = new rem_port(rem_port::XNET, 0); TEXT buffer[BUFFER_TINY]; ISC_get_host(buffer, sizeof(buffer)); @@ -697,8 +697,7 @@ } -// Third param "ast" is unused. -static rem_port* aux_connect(rem_port* port, PACKET* packet) +static rem_port* aux_connect(rem_port* port, PACKET* /*packet*/) { /************************************** * @@ -720,7 +719,6 @@ return port; } - rem_port* new_port = NULL; XCC parent_xcc = NULL; XCC xcc = NULL; TEXT name_buffer[BUFFER_TINY]; @@ -789,11 +787,9 @@ ((UCHAR *) xcc->xcc_mapped_addr + sizeof(struct xps) + (XNET_EVENT_SPACE)); // alloc new port and link xcc to it - new_port = alloc_port(NULL, - channel_c2s_client_ptr, - xcc->xcc_send_channel->xch_size, - channel_s2c_client_ptr, - xcc->xcc_recv_channel->xch_size); + rem_port* const new_port = alloc_port(NULL, + channel_c2s_client_ptr, xcc->xcc_send_channel->xch_size, + channel_s2c_client_ptr, xcc->xcc_recv_channel->xch_size); port->port_async = new_port; new_port->port_flags = port->port_flags & PORT_no_oob; @@ -845,29 +841,25 @@ * **************************************/ - rem_port* new_port = NULL; - XCC parent_xcc = NULL; XCC xcc = NULL; TEXT name_buffer[BUFFER_TINY]; - XPS xps = NULL; - XPM xpm = NULL; try { // make a new xcc - parent_xcc = port->port_xcc; - xps = (XPS) parent_xcc->xcc_mapped_addr; + XCC parent_xcc = port->port_xcc; + XPS xps = (XPS) parent_xcc->xcc_mapped_addr; xcc = new struct xcc; - xpm = xcc->xcc_xpm = parent_xcc->xcc_xpm; + XPM xpm = xcc->xcc_xpm = parent_xcc->xcc_xpm; xcc->xcc_map_num = parent_xcc->xcc_map_num; xcc->xcc_slot = parent_xcc->xcc_slot; DuplicateHandle(GetCurrentProcess(), parent_xcc->xcc_proc_h, GetCurrentProcess(), &xcc->xcc_proc_h, 0, FALSE, DUPLICATE_SAME_ACCESS); - xcc->xcc_flags = 0; + xcc->xcc_flags = XCCF_ASYNC; xcc->xcc_map_handle = parent_xcc->xcc_map_handle; xcc->xcc_mapped_addr = parent_xcc->xcc_mapped_addr; xcc->xcc_xpm->xpm_count++; @@ -923,11 +915,9 @@ ((UCHAR *) xcc->xcc_mapped_addr + sizeof(struct xps)); // alloc new port and link xcc to it - new_port = alloc_port(NULL, - channel_s2c_client_ptr, - xcc->xcc_send_channel->xch_size, - channel_c2s_client_ptr, - xcc->xcc_recv_channel->xch_size); + rem_port* const new_port = alloc_port(NULL, + channel_s2c_client_ptr, xcc->xcc_send_channel->xch_size, + channel_c2s_client_ptr, xcc->xcc_recv_channel->xch_size); port->port_async = new_port; new_port->port_xcc = xcc; @@ -1002,7 +992,7 @@ } XPM xpm = xcc->xcc_xpm; - if (xpm) { + if (xpm && !(xcc->xcc_flags & XCCF_ASYNC)) { cleanup_mapping(xpm); } @@ -1320,12 +1310,10 @@ UCHAR* const channel_c2s_client_ptr = start_ptr; UCHAR* const channel_s2c_client_ptr = start_ptr + avail; - rem_port* port = - alloc_port(0, - channel_c2s_client_ptr, - xcc->xcc_send_channel->xch_size, - channel_s2c_client_ptr, - xcc->xcc_recv_channel->xch_size); + rem_port* const port = + alloc_port(NULL, + channel_c2s_client_ptr, xcc->xcc_send_channel->xch_size, + channel_s2c_client_ptr, xcc->xcc_recv_channel->xch_size); status_vector[1] = FB_SUCCESS; port->port_status_vector = status_vector; @@ -1343,7 +1331,8 @@ cleanup_comm(xcc); else if (xpm) cleanup_mapping(xpm); - else if (file_handle) { + else if (file_handle) + { if (mapped_address) { UnmapViewOfFile(mapped_address); } @@ -1469,17 +1458,13 @@ * **************************************/ - // If this is a sub-port, unlink it from it's parent - if (port->port_async) { disconnect(port->port_async); port->port_async = NULL; } - rem_port* const parent = port->port_parent; - if (parent != NULL) { + // If this is a sub-port, unlink it from it's parent port->unlinkParent(); - } if (port->port_flags & PORT_server) xnet_ports->unRegisterPort(port); @@ -1552,7 +1537,7 @@ } } -static int cleanup_ports(const int, const int, void* arg) +static int cleanup_ports(const int, const int, void* /*arg*/) { /************************************** * @@ -1702,7 +1687,7 @@ } -static int xnet_destroy( XDR * xdrs) +static int xnet_destroy( XDR* /*xdrs*/) { /************************************** * @@ -1795,7 +1780,8 @@ while (bytecount && !xnet_shutdown) { #ifdef SUPERCLIENT - if (xpm->xpm_flags & XPMF_SERVER_SHUTDOWN) { + if (xpm->xpm_flags & XPMF_SERVER_SHUTDOWN) + { if (!(xcc->xcc_flags & XCCF_SERVER_SHUTDOWN)) { xcc->xcc_flags |= XCCF_SERVER_SHUTDOWN; xnet_error(port, isc_lost_db_connection, 0); @@ -1809,7 +1795,8 @@ else to_copy = xdrs->x_handy; - if (xdrs->x_handy) { + if (xdrs->x_handy) + { if (to_copy == sizeof(SLONG)) *((SLONG*)buff) = *((SLONG*)xdrs->x_private); else @@ -2602,11 +2589,9 @@ // finally, allocate and set the port structure for this client - port = alloc_port(0, - channel_s2c_data_buffer, - xcc->xcc_send_channel->xch_size, - channel_c2s_data_buffer, - xcc->xcc_recv_channel->xch_size); + port = alloc_port(NULL, + channel_s2c_data_buffer, xcc->xcc_send_channel->xch_size, + channel_c2s_data_buffer, xcc->xcc_recv_channel->xch_size); port->port_xcc = xcc; port->port_server_flags |= SRVR_server; Index: xnet.h =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/xnet.h,v retrieving revision 1.16.6.3 retrieving revision 1.16.6.4 diff -b -U3 -r1.16.6.3 -r1.16.6.4 --- xnet.h 15 Feb 2009 17:24:45 -0000 1.16.6.3 +++ xnet.h 8 Jun 2009 21:46:27 -0000 1.16.6.4 @@ -94,7 +94,7 @@ { ULONG xch_length; // message length ULONG xch_size; // channel data size - USHORT xch_flags; // flags + USHORT xch_flags; // flags, UNUSED ULONG xch_dummy1; // for binary compatibility ULONG xch_dummy2; // with 32-bit builds } *XCH; @@ -126,6 +126,8 @@ // XCC structure flags const ULONG XCCF_SERVER_SHUTDOWN = 1; // server has shutdown detected +const ULONG XCCF_ASYNC = 2; // secondary XCC for events processing + // This structure (xps) is mapped to the start of the allocated // communications area between the client and server @@ -138,7 +140,7 @@ PID_T xps_client_proc_id; // client's process id USHORT xps_flags; // flags word struct xch xps_channels[4]; // comm channels - ULONG xps_data[1]; // start of data area + ULONG xps_data[1]; // start of data area, UNUSED at least directly } *XPS; // XPS flags @@ -173,21 +175,21 @@ // Windows names used to identify various named objects -const char* XNET_MAPPED_FILE_NAME = "%s_MAP_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_MAPPED_FILE_NAME = "%s_MAP_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_CONNECT_MAP = "%s_CONNECT_MAP"; -const char* XNET_CONNECT_MUTEX = "%s_CONNECT_MUTEX"; -const char* XNET_CONNECT_EVENT = "%s_CONNECT_EVENT"; -const char* XNET_RESPONSE_EVENT = "%s_RESPONSE_EVENT"; - -const char* XNET_E_C2S_DATA_CHAN_FILLED = "%s_E_C2S_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_E_C2S_DATA_CHAN_EMPTED = "%s_E_C2S_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_E_S2C_DATA_CHAN_FILLED = "%s_E_S2C_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_E_S2C_DATA_CHAN_EMPTED = "%s_E_S2C_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; - -const char* XNET_E_C2S_EVNT_CHAN_FILLED = "%s_E_C2S_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_E_C2S_EVNT_CHAN_EMPTED = "%s_E_C2S_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_E_S2C_EVNT_CHAN_FILLED = "%s_E_S2C_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; -const char* XNET_E_S2C_EVNT_CHAN_EMPTED = "%s_E_S2C_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_CONNECT_MAP = "%s_CONNECT_MAP"; +const char* const XNET_CONNECT_MUTEX = "%s_CONNECT_MUTEX"; +const char* const XNET_CONNECT_EVENT = "%s_CONNECT_EVENT"; +const char* const XNET_RESPONSE_EVENT = "%s_RESPONSE_EVENT"; + +const char* const XNET_E_C2S_DATA_CHAN_FILLED = "%s_E_C2S_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_E_C2S_DATA_CHAN_EMPTED = "%s_E_C2S_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_E_S2C_DATA_CHAN_FILLED = "%s_E_S2C_DATA_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_E_S2C_DATA_CHAN_EMPTED = "%s_E_S2C_DATA_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; + +const char* const XNET_E_C2S_EVNT_CHAN_FILLED = "%s_E_C2S_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_E_C2S_EVNT_CHAN_EMPTED = "%s_E_C2S_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_E_S2C_EVNT_CHAN_FILLED = "%s_E_S2C_EVNT_FILLED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; +const char* const XNET_E_S2C_EVNT_CHAN_EMPTED = "%s_E_S2C_EVNT_EMPTED_%"ULONGFORMAT"_%"ULONGFORMAT"_%"ULONGFORMAT; #endif // REMOTE_XNET_H Index: xnet_proto.h =================================================================== RCS file: /cvsroot/firebird/firebird2/src/remote/xnet_proto.h,v retrieving revision 1.16.20.1 retrieving revision 1.16.20.2 diff -b -U3 -r1.16.20.1 -r1.16.20.2 --- xnet_proto.h 30 May 2008 01:42:14 -0000 1.16.20.1 +++ xnet_proto.h 8 Jun 2009 21:46:27 -0000 1.16.20.2 @@ -32,8 +32,8 @@ #define rem_port void #endif -rem_port* XNET_analyze(const Firebird::PathName&, ISC_STATUS*, const TEXT*, const TEXT*, bool); -rem_port* XNET_connect(const TEXT*, struct packet*, ISC_STATUS*, USHORT); +rem_port* XNET_analyze(const Firebird::PathName&, ISC_STATUS*, /*const TEXT*, const TEXT*,*/ bool); +rem_port* XNET_connect(/*const TEXT*,*/ struct packet*, ISC_STATUS*, USHORT); #ifndef SUPERCLIENT rem_port* XNET_reconnect(ULONG, ISC_STATUS*); |