Skip to content

Commit 04e1c3e

Browse files
committed
Correct handling of errors returned by request's getInfo()
1 parent 7d13e17 commit 04e1c3e

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

src/remote/remote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted
17041704
ISC_STATUS put_segment(P_OP, P_SGMT*, PACKET*);
17051705
ISC_STATUS put_slice(P_SLC*, PACKET*);
17061706
ISC_STATUS que_events(P_EVENT*, PACKET*);
1707-
ISC_STATUS receive_after_start(P_DATA*, PACKET*, Firebird::IStatus*);
1707+
ISC_STATUS receive_after_start(P_DATA* data, PACKET* sendL, Firebird::CheckStatusWrapper* status_vector);
17081708
ISC_STATUS receive_msg(P_DATA*, PACKET*);
17091709
ISC_STATUS seek_blob(P_SEEK*, PACKET*);
17101710
ISC_STATUS send_msg(P_DATA*, PACKET*);

src/remote/server/server.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,10 +1275,10 @@ static void addClumplets(ClumpletWriter*, const ParametersSet&, const rem_port*
12751275

12761276
static void cancel_operation(rem_port*, USHORT);
12771277

1278-
static bool check_request(Rrq*, USHORT, USHORT);
1278+
static bool check_request(Rrq* request, USHORT incarnation, USHORT msg_number, CheckStatusWrapper* status);
12791279
static USHORT check_statement_type(Rsr*);
12801280

1281-
static bool get_next_msg_no(Rrq*, USHORT, USHORT*);
1281+
static bool get_next_msg_no(Rrq* request, USHORT incarnation, USHORT* msg_number, CheckStatusWrapper* status);
12821282
static Rtr* make_transaction(Rdb*, ITransaction*);
12831283
static void ping_connection(rem_port*, PACKET*);
12841284
static bool process_packet(rem_port* port, PACKET* sendL, PACKET* receive, rem_port** result);
@@ -2819,7 +2819,7 @@ static void cancel_operation(rem_port* port, USHORT kind)
28192819
}
28202820

28212821

2822-
static bool check_request(Rrq* request, USHORT incarnation, USHORT msg_number)
2822+
static bool check_request(Rrq* request, USHORT incarnation, USHORT msg_number, CheckStatusWrapper* status)
28232823
{
28242824
/**************************************
28252825
*
@@ -2834,7 +2834,7 @@ static bool check_request(Rrq* request, USHORT incarnation, USHORT msg_number)
28342834
**************************************/
28352835
USHORT n;
28362836

2837-
if (!get_next_msg_no(request, incarnation, &n))
2837+
if (!get_next_msg_no(request, incarnation, &n, status))
28382838
return false;
28392839

28402840
return msg_number == n;
@@ -4430,7 +4430,7 @@ ISC_STATUS rem_port::fetch(P_SQLDATA * sqldata, PACKET* sendL, bool scroll)
44304430
}
44314431

44324432

4433-
static bool get_next_msg_no(Rrq* request, USHORT incarnation, USHORT * msg_number)
4433+
static bool get_next_msg_no(Rrq* request, USHORT incarnation, USHORT * msg_number, CheckStatusWrapper* status)
44344434
{
44354435
/**************************************
44364436
*
@@ -4443,14 +4443,12 @@ static bool get_next_msg_no(Rrq* request, USHORT incarnation, USHORT * msg_numbe
44434443
* in the request.
44444444
*
44454445
**************************************/
4446-
LocalStatus ls;
4447-
CheckStatusWrapper status_vector(&ls);
44484446
UCHAR info_buffer[128];
44494447

4450-
request->rrq_iface->getInfo(&status_vector, incarnation,
4448+
request->rrq_iface->getInfo(status, incarnation,
44514449
sizeof(request_info), request_info, sizeof(info_buffer), info_buffer);
44524450

4453-
if (status_vector.getState() & IStatus::STATE_ERRORS)
4451+
if (status->getState() & IStatus::STATE_ERRORS)
44544452
return false;
44554453

44564454
bool result = false;
@@ -5614,7 +5612,7 @@ ISC_STATUS rem_port::que_events(P_EVENT * stuff, PACKET* sendL)
56145612
}
56155613

56165614

5617-
ISC_STATUS rem_port::receive_after_start(P_DATA* data, PACKET* sendL, IStatus* status_vector)
5615+
ISC_STATUS rem_port::receive_after_start(P_DATA* data, PACKET* sendL, CheckStatusWrapper* status_vector)
56185616
{
56195617
/**************************************
56205618
*
@@ -5636,7 +5634,7 @@ ISC_STATUS rem_port::receive_after_start(P_DATA* data, PACKET* sendL, IStatus* s
56365634
// Figure out the number of the message that we're stalled on.
56375635

56385636
USHORT msg_number;
5639-
if (!get_next_msg_no(requestL, level, &msg_number))
5637+
if (!get_next_msg_no(requestL, level, &msg_number, status_vector))
56405638
return this->send_response(sendL, 0, 0, status_vector, false);
56415639

56425640
sendL->p_operation = op_response_piggyback;
@@ -5751,9 +5749,12 @@ ISC_STATUS rem_port::receive_msg(P_DATA * data, PACKET* sendL)
57515749
RMessage* next = message->msg_next;
57525750

57535751
if ((next == message || !next->msg_address) &&
5754-
!check_request(requestL, data->p_data_incarnation, msg_number))
5752+
!check_request(requestL, data->p_data_incarnation, msg_number, &status_vector))
57555753
{
5756-
// We've reached the end of the RSE - don't prefetch and flush
5754+
if (status_vector.getState() & IStatus::STATE_ERRORS)
5755+
return this->send_response(sendL, 0, 0, &status_vector, false);
5756+
5757+
// We've reached the end of the RSE or ReceiveNode/SelectMessageNode - don't prefetch and flush
57575758
// everything we've buffered so far
57585759

57595760
count2 = 0;
@@ -5784,8 +5785,21 @@ ISC_STATUS rem_port::receive_msg(P_DATA * data, PACKET* sendL)
57845785
while (message->msg_address && message->msg_next != tail->rrq_xdr)
57855786
message = message->msg_next;
57865787

5787-
for (; count2 && check_request(requestL, data->p_data_incarnation, msg_number); --count2)
5788+
for (; count2; --count2)
57885789
{
5790+
if (!check_request(requestL, data->p_data_incarnation, msg_number, &status_vector))
5791+
{
5792+
if (status_vector.getState() & IStatus::STATE_ERRORS)
5793+
{
5794+
// If already have an error queued, don't overwrite it
5795+
5796+
if (requestL->rrqStatus.isSuccess())
5797+
requestL->rrqStatus.save(&status_vector);
5798+
}
5799+
5800+
break;
5801+
}
5802+
57895803
if (message->msg_address)
57905804
{
57915805
if (!prior)

0 commit comments

Comments
 (0)