Added the missing ERR packet detection to modutil functions.
This commit is contained in:
Markus Makela
2015-01-13 21:32:04 +02:00
parent d194af0733
commit 7f4675cd57
3 changed files with 89 additions and 35 deletions

View File

@ -496,26 +496,36 @@ return_packetbuf:
/**
* Count the number of EOF packets in the buffer.
* Count the number of EOF, OK or ERR packets in the buffer.
* @param reply Buffer to use
* @param use_ok Whether the DEPRECATE_EOF flag is set
* @param n_found If there were previous packets found
* @return Number of EOF packets
*/
int
modutil_count_EOF(GWBUF *reply)
modutil_count_signal_packets(GWBUF *reply,int use_ok, int n_found)
{
unsigned char* ptr = (unsigned char*) reply->start;
unsigned char* end = (unsigned char*) reply->end;
int pktlen,eof = 0;
int pktlen,pkt = 0;
while(ptr < end)
{
pktlen = gw_mysql_get_byte3(ptr) + 4;
if(PTR_IS_EOF(ptr))
{
eof++;
}
ptr += pktlen;
if(PTR_IS_ERR(ptr) || (PTR_IS_EOF(ptr) && !use_ok) || (use_ok && PTR_IS_OK(ptr)))
{
if(n_found)
{
if(ptr + pktlen >= end)
pkt++;
}
else
{
pkt++;
}
}
ptr += pktlen;
}
return eof;
return pkt;
}