8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:03:04 +01:00

Fixed CORE-1357.

This commit is contained in:
dimitr 2008-04-20 13:55:25 +00:00
parent 78fa0a6dc9
commit b5950f654b
4 changed files with 27 additions and 25 deletions

View File

@ -330,7 +330,7 @@ static rem_port* receive(rem_port*, PACKET *);
static rem_port* select_accept(rem_port*);
static rem_port* select_port(rem_port*, SLCT *);
static rem_port* select_multi(rem_port*, UCHAR* buffer, SSHORT bufsize, SSHORT* length);
static bool select_multi(rem_port*, UCHAR* buffer, SSHORT bufsize, SSHORT* length, rem_port*& port);
static int select_wait(rem_port*, SLCT *);
static int send_full(rem_port*, PACKET *);
static int send_partial(rem_port*, PACKET *);
@ -2361,7 +2361,7 @@ static rem_port* receive( rem_port* main_port, PACKET * packet)
#endif //SUPERSERVER
}
static rem_port* select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize, SSHORT* length)
static bool select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize, SSHORT* length, rem_port*& port)
{
/**************************************
*
@ -2377,21 +2377,21 @@ static rem_port* select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize
*
**************************************/
fb_assert(main_port->port_server_flags & SRVR_multi_client);
for (;;)
{
rem_port* port = select_port(main_port, &INET_select);
port = select_port(main_port, &INET_select);
if (port == main_port)
{
if (port = select_accept(main_port))
if ( (port = select_accept(main_port)) )
{
if (!packet_receive(port, buffer, bufsize, length))
{
*length = 0;
}
return port;
return (*length) ? true : false;
}
continue;
}
if (port)
@ -2400,20 +2400,24 @@ static rem_port* select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize
{
port->port_dummy_timeout = port->port_dummy_packet_interval;
if (port->port_flags & PORT_async ||
port->port_protocol < PROTOCOL_VERSION8) continue;
port->port_protocol < PROTOCOL_VERSION8)
{
continue;
}
*length = 0;
return port;
return true;
}
if (!packet_receive(port, buffer, bufsize, length))
{
*length = 0;
}
return port;
return (*length) ? true : false;
}
if (!select_wait(main_port, &INET_select))
{
return NULL;
port = NULL;
return false;
}
}
}

View File

@ -809,9 +809,9 @@ rem_port* rem_port::receive(PACKET* pckt)
return (*this->port_receive_packet)(this, pckt);
}
rem_port* rem_port::select_multi(UCHAR* buffer, SSHORT bufsize, SSHORT* length)
bool rem_port::select_multi(UCHAR* buffer, SSHORT bufsize, SSHORT* length, rem_port*& port)
{
return (*this->port_select_multi)(this, buffer, bufsize, length);
return (*this->port_select_multi)(this, buffer, bufsize, length, port);
}
XDR_INT rem_port::send(PACKET* pckt)

View File

@ -396,7 +396,7 @@ struct rem_port
XDR_INT (*port_send_partial)(rem_port*, PACKET*);
t_port_connect port_connect; /* Establish secondary connection */
rem_port* (*port_request)(rem_port*, PACKET*); /* Request to establish secondary connection */
rem_port* (*port_select_multi)(rem_port*, UCHAR*, SSHORT, SSHORT*); // get packet from active port
bool (*port_select_multi)(rem_port*, UCHAR*, SSHORT, SSHORT*, rem_port*&); // get packet from active port
rdb* port_context;
t_event_ast port_ast; /* AST for events */
@ -437,8 +437,8 @@ struct rem_port
XDR_INT send_partial(PACKET* pckt);
rem_port* connect(PACKET* pckt, t_event_ast);
rem_port* request(PACKET* pckt);
rem_port* select_multi(UCHAR* buffer, SSHORT bufsize, SSHORT* length);
bool select_multi(UCHAR* buffer, SSHORT bufsize, SSHORT* length, rem_port*& port);
/* TMN: The following member functions are conceptually private
* to server.cpp and should be _made_ private in due time!
* That is, if we don't factor these method out.

View File

@ -456,9 +456,11 @@ void SRVR_multi_thread( rem_port* main_port, USHORT flags)
UCHAR buffer[MAX_PACKET_SIZE];
SSHORT dataSize = main_port->port_buff_size > sizeof(buffer) ?
sizeof(buffer) : main_port->port_buff_size;
if (!port)
bool ok = true;
if (!port)
{
if (!(port = main_port->select_multi(buffer, dataSize, &dataSize)))
ok = main_port->select_multi(buffer, dataSize, &dataSize, port);
if (!port)
{
gds__log("SRVR_multi_thread/RECEIVE: error on main_port, shutting down");
THREAD_EXIT();
@ -474,15 +476,12 @@ void SRVR_multi_thread( rem_port* main_port, USHORT flags)
{
dataSize = port->port_receive.x_handy;
}
// gds__log("queue=%d", port->port_queue->getCount());
if (dataSize) {
port->receive(&request->req_receive);
port->port_qoffset = 0;
// gds__log("dats=%d", dataSize);
if (request->req_receive.p_operation == op_partial)
{
// gds__log("Partial");
free_request(request);
request = 0;
port = 0;
@ -491,9 +490,8 @@ void SRVR_multi_thread( rem_port* main_port, USHORT flags)
}
else
{
request->req_receive.p_operation = op_exit;
request->req_receive.p_operation = ok ? op_dummy : op_exit;
}
// gds__log("op=%d ds=%d", request->req_receive.p_operation, dataSize);
port->port_queue->clear();
request->req_port = port;