Fix hang on multi-statemet query

If multiple queries that only generate OK packets were executed, the
result returned by the server would consist of a chain of OK packets. This
special case needs to be handled by the modutil_count_signal_packets.

The current implementation is very ugly as it simulates a result with at
least one resultset in it. A better implementation would hide it behind a
simple boolean return value and an internal state object.
This commit is contained in:
Markus Mäkelä 2017-10-10 16:37:02 +03:00
parent 820e86ac7d
commit c3627c83be

View File

@ -636,6 +636,7 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_out, modu
size_t offset = 0;
bool skip_next = state ? state->state : false;
bool more = false;
bool only_ok = true;
while (offset < len)
{
@ -682,6 +683,10 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_out, modu
uint16_t* status = (uint16_t*)ptr;
more = (*status) & SERVER_MORE_RESULTS_EXIST;
}
else
{
only_ok = false;
}
}
if (offset + pktlen >= len || (eof + err + n_found) >= 2)
@ -709,6 +714,12 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_out, modu
}
*more_out = more;
if (only_ok && !more)
{
total = 2;
}
return total;
}