Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

fix issue 47 Connection obj cant search the right result #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 51 additions & 22 deletions lib/Connection.cpp
Expand Up @@ -83,6 +83,7 @@ Connection::Connection (UMConnectionCAPI *_capi)
m_errno = -1;
memcpy (&m_capi, _capi, sizeof (UMConnectionCAPI));
m_dbgMethodProgress = 0;
m_dbgFailedRecv = 0;
m_errorType = UME_OTHER;
}

Expand Down Expand Up @@ -736,6 +737,7 @@ void *Connection::query(const char *_query, size_t _cbQuery)
return NULL;
}


size_t len = _cbQuery;

if (len > m_writer.getSize () - (MYSQL_PACKET_HEADER_SIZE + 1))
Expand All @@ -762,36 +764,63 @@ void *Connection::query(const char *_query, size_t _cbQuery)
{
PRINTMARK();
m_dbgMethodProgress --;
m_dbgFailedRecv ++;
return NULL;
}

UINT8 result = m_reader.readByte();

switch (result)
void * topResult = NULL;
bool again;
do
{
case 0x00:
PRINTMARK();
m_dbgMethodProgress --;
return handleOKPacket();
again = false;

case 0xff:
PRINTMARK();
handleErrorPacket();
m_dbgMethodProgress --;
return NULL;
UINT8 result = m_reader.readByte();

case 0xfe:
PRINTMARK();
setError ("Unexpected EOF when decoding result", 0, UME_OTHER);
m_dbgMethodProgress --;
return NULL;
switch (result)
{
case 0x00:
PRINTMARK();
m_dbgMethodProgress --;
topResult = handleOKPacket();
break;

case 0xff:
PRINTMARK();
handleErrorPacket();
m_dbgMethodProgress --;
topResult = NULL;
break;

default:
PRINTMARK();
m_dbgMethodProgress --;
return handleResultPacket((int)result);
}
case 0xfe:
PRINTMARK();
setError ("Unexpected EOF when decoding result", 0, UME_OTHER);
m_dbgMethodProgress --;
topResult = NULL;
break;

default:
PRINTMARK();
m_dbgMethodProgress --;
topResult = handleResultPacket((int)result);
break;
}


if (m_dbgFailedRecv > 0)
{
again = true;
if (!recvPacket())
{
m_dbgMethodProgress --;
return NULL;
}

m_dbgFailedRecv --;
}

}while(again);

return topResult;

PRINTMARK();
m_dbgMethodProgress --;
Expand Down
3 changes: 2 additions & 1 deletion lib/Connection.h
Expand Up @@ -108,6 +108,7 @@ class Connection
UMConnectionCAPI m_capi;

int m_dbgMethodProgress;
int m_dbgFailedRecv;

public:

Expand Down Expand Up @@ -145,4 +146,4 @@ class Connection
protected:
};

#endif
#endif