Core/DBLayer:

- Rewrite Field class to be able to store both binary prepared statement data and data from adhoc query resultsets
- Buffer the data of prepared statements using ResultSet and Field classes and let go of mysql c api structures after PreparedResultSet constructor. Fixes a race condition and thus a possible crash/data corruption (issue pointed out to Derex, basic suggestion by raczman)
- Conform PreparedResultSet and ResultSet to the same design standards, and using Field class as data buffer class for both
* NOTE: This means the fetching methods are uniform again, using ¨Field* fields = result->Fetch();¨ and access to elements trough fields[x].
* NOTE: for access to the correct row in prepared statements, ¨Field* fields = result->Fetch();¨ must ALWAYS be called inside the do { }while(result->NextRow()) loop.
* NOTE: This means that Field::GetString() returns std::string object and Field::GetCString() returns const char* pointer.

Still experimental and all that jazz, not recommended for production servers until feedback is given.

--HG--
branch : trunk
This commit is contained in:
Machiavelli committed 2010-09-24 22:16:21 +02:00
1 parent b46b498141
commit 3c6dc32030
47 files changed
+1003 -875

No files matched your search

+4 -4
View File
@@ -851,8 +851,8 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
N.SetHexStr ("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
g.SetDword (7);
v.SetHexStr(fields[4].GetString());
s.SetHexStr (fields[5].GetString());
v.SetHexStr(fields[4].GetCString());
s.SetHexStr (fields[5].GetCString());
const char* sStr = s.AsHexStr(); //Must be freed by OPENSSL_free()
const char* vStr = v.AsHexStr(); //Must be freed by OPENSSL_free()
@@ -867,7 +867,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
///- Re-check ip locking (same check as in realmd).
if (fields[3].GetUInt8() == 1) // if ip is locked
{
if (strcmp (fields[2].GetString(), GetRemoteAddress().c_str()))
if (strcmp (fields[2].GetCString(), GetRemoteAddress().c_str()))
{
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
packet << uint8 (AUTH_FAILED);
@@ -884,7 +884,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
security = SEC_ADMINISTRATOR;
*/
K.SetHexStr (fields[1].GetString());
K.SetHexStr (fields[1].GetCString());
time_t mutetime = time_t (fields[7].GetUInt64());