You could try using mysql_query or threaded queries with y_inline.
Method #1 - mysql_query Code:
[...] Code:
[...] |
Sorry, but it actually seems like that made it even worse. It still crashes at __kernel_vsyscal. Can it be related to the connection being idle for a while?
|
Hi, i need a bit of help.
I'm using the callback OnQueryError and checking if its CR_SERVER_GONE_ERROR, to lock the server and avoid trouble. But the problem is that we lost connection with the database, but the server was kept on. Errors: http://pastebin.com/fvBNWfQc Script: Code:
[...] |
No, I don't think so.
I've compiled another version for you. This time there's no possible fix included; this version is purely for debugging purposes. I've compiled the MySQL C library (libmysqlclient.a) and the plugin itself with debug information, so your next crash report should have more useful stuff in it. mysql-r39-2d-debian7.zip |
[18:16:56] Incoming connection: x.x.75.67:52311 id: 0 [18:16:56] [join] Vince0789 has joined the server (0:x.x.75.67)
[18:16:56] [DEBUG] cache_is_valid - cache_id: 0, connection: 3 [18:16:56] [DEBUG] cache_is_valid - cache_id: 1, connection: 3 [18:16:56] [DEBUG] cache_set_active - cache_id: 1, connection: 3 [18:16:56] [DEBUG] CMySQLHandle::SetActiveResult - result is now active [18:16:56] [DEBUG] cache_get_row - row: 0, field_idx: 0, connection: 3, max_len: 28 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "Paramedics" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 1, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '1', data: "1" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 7, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '7', data: "0" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 9, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '9', data: "0" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 11, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '11', data: "0" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 8, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '8', data: "0" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 10, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '10', data: "0" [18:16:56] [DEBUG] cache_get_row_int - row: 0, field_idx: 12, connection: 3 [18:16:56] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '12', data: "0" [18:17:07] [DEBUG] mysql_format - connection: 3, len: 184, format: "SELECT IFNULL(MIN(time_taken),0) AS record_time FROM stats_mission s INNER JOIN stats_mission_race r ON r.statid = s.statid WHER..." [18:17:07] [DEBUG] mysql_tquery - connection: 3, query: "SELECT IFNULL(MIN(time_taken),0) AS record_time FROM stats_missi", callback: "GetPlayerRecordTime", format: "d" [18:17:07] [DEBUG] cache_set_active - cache_id: 3, connection: 3 [18:17:07] [DEBUG] CMySQLHandle::SetActiveResult - result is now active [18:17:07] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "0" [18:17:07] [DEBUG] cache_get_row_float - row: 0, field_idx: 1, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '1', data: "-1988" [18:17:07] [DEBUG] cache_get_row_float - row: 0, field_idx: 2, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '2', data: "-672.7" [18:17:07] [DEBUG] cache_get_row_float - row: 0, field_idx: 3, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '3', data: "32.4" [18:17:07] [DEBUG] cache_get_row_float - row: 1, field_idx: 1, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '1', field: '1', data: "-2202.6" [18:17:07] [DEBUG] cache_get_row_float - row: 1, field_idx: 2, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '1', field: '2', data: "-445.7" [18:17:07] [DEBUG] cache_get_row_float - row: 1, field_idx: 3, connection: 3 [18:17:07] [DEBUG] CMySQLResult::GetRowData - row: '1', field: '3', data: "50.5" [18:17:07] [DEBUG] CMySQLQuery::Execute[GetPlayerRecordTime] - starting query execution
public OnPlayerConnect(playerid) {
//Some checks..
SendToLobbyScreen(playerid);
}
stock SendToLobbyScreen(playerid) {
print("SendToLobbyScreen");
ShowLobbyScreen(playerid); //Show them the lobby screen (custom camera and textdraws).
PrepareAccount(playerid); //Call the PrepareAccount function.
return 1;
}
stock PrepareAccount(playerid) { //Readies the players enum to be filled in with data that comes from the SELECT query.
print("PrepareAccount");
//Get the name of the player.
GetPlayerName(playerid, AccountInfo[playerid][pName], MPN + 1);
new ORM:ormid;
//QUESTION HERE
if(!AccountInfo[playerid][ORM_ID]) { //Is this going to work as intended?
//This is called when the player only has to log in.
printf("Creating new ORM:ID for %s.", AccountInfo[playerid][pName]);
ormid = AccountInfo[playerid][ORM_ID] = orm_create("accounts");
} else {
ormid = AccountInfo[playerid][ORM_ID];
//This is called when a player registers and is then asked to log back in. Instead of creating a new ORM instance for the already connected player, i simply just use the existing ORM instance.
printf("Using existing ORM:ID for %s.", AccountInfo[playerid][pName]);
}
orm_addvar_int(ormid, AccountInfo[playerid][pID], "pID");
orm_addvar_string(ormid, AccountInfo[playerid][pName], MPN+1, "pName");
orm_addvar_string(ormid, AccountInfo[playerid][pPassword], 129, "pPassword");
orm_addvar_string(ormid, AccountInfo[playerid][pRegisteredIP], 16, "pRegisteredIP");
orm_addvar_string(ormid, AccountInfo[playerid][pLastIP], 16, "pLastIP");
orm_addvar_string(ormid, AccountInfo[playerid][pRecoveryQuestion], 80, "pRecoveryQuestion");
orm_addvar_string(ormid, AccountInfo[playerid][pRecoveryAnswer], 80, "pRecoveryAnswer");
orm_addvar_int(ormid, AccountInfo[playerid][pRegisterDate], "pRegisterDate");
orm_addvar_int(ormid, AccountInfo[playerid][pRegistered], "pRegistered");
//---------------------------------------------------------------------------
orm_addvar_int(ormid, AccountInfo[playerid][pAdminLevel], "pAdminLevel");
orm_addvar_string(ormid, AccountInfo[playerid][pAdminPassword], 129, "pAdminPassword");
orm_addvar_int(ormid, AccountInfo[playerid][pAdminActions], "pAdminActions");
//---------------------------------------------------------------------------
orm_addvar_float(ormid, AccountInfo[playerid][pLastXPos], "pLastXPos");
orm_addvar_float(ormid, AccountInfo[playerid][pLastYPos], "pLastYPos");
orm_addvar_float(ormid, AccountInfo[playerid][pLastZPos], "pLastZPos");
orm_addvar_float(ormid, AccountInfo[playerid][pLastAPos], "pLastAPos");
orm_addvar_int(ormid, AccountInfo[playerid][pInterior], "pInterior");
orm_addvar_int(ormid, AccountInfo[playerid][pVirtualWorld], "pVirtualWorld");
//---------------------------------------------------------------------------
orm_addvar_int(ormid, AccountInfo[playerid][pPlayerState], "pPlayerState");
orm_setkey(ormid, "pName"); //Set the 'SELECT' query's WHERE id to the "Name" field.
orm_select(ormid, "OnAccountDataLoad", "d", playerid); //Send the SELECT query and go to the OnPlayerDataLoad callback when it's done.
}
public OnAccountDataLoad(playerid) { //This callback is called after the SELECT query finishes.
new
ip[16];
GetPlayerIp(playerid, ip, 16); //Get the players IP Address.
AccountInfo[playerid][pLastIP] = ip; //Assign the ip address to the account enum, we do this here as you can't use GetPlayerIp under OnPlayerDisconnect and we need to wait until all the MySQL data has been retrieved and applied.
CheckIPBans(playerid); //Check the players IP Address for any currently banned accounts as he may be ban evading. Possibly issue: same IP address players.
//printf("OnPlayerDataLoad");
switch(orm_errno(AccountInfo[playerid][ORM_ID])) {
case ERROR_OK: { //If the account EXISTS.
CheckAccountBans(playerid); //Check the players Account for bans. May need to make it so you are checked when you try to log in.
}
case ERROR_NO_DATA: { //If the account does NOT EXIST.
//Not sure if this is needed yet.
SCM(playerid, COLOR_LOBBY, "Hello! Welcome to "#SERVER_NAME"! Please click the Register button to get started!");
}
}
orm_setkey(AccountInfo[playerid][ORM_ID], "pID"); // Set a new key to use WHERE `pID` = ... in future queries!
return 1;
}
printf("NUMBER OF ROWS RETURNED : %d", cache_num_rows());
cache_get_row(0, 0, test);
printf("NAME : %s", test);
cache_get_row(0, 2, actual_pass);
cache_get_row(0, 3, salt);
strcat(salted, password);
strcat(salted, ".");
strcat(salted, salt);
whirlpool(salted, hashed, WH_LENGHT+1);
printf("PASSWORD (good one) : %s", actual_pass);
printf("SALT : %s", salt);
printf("SALTED PASSWORD : %s", salted);
printf("HASHED SALTED : %s", hashed);
[23:40:01] NUMBER OF ROWS RETURNED : 1 [23:40:01] NAME : [23:40:01] PASSWORD (good one) : [23:40:01] SALT : [23:40:01] SALTED PASSWORD : ;dsnfkjfqshfsd [23:40:01] HASHED SALTED : A5FB83325A73B2498A74B68866F35CBB1E77B9A5D4E33F06986725B28B697FD150FF57D8CCB5C1DB6715CFBFFB0514FC0F2A624058748C0655C7F3E83FB071E8
Originally Posted by S4t3K
Hi.
I'm having an issue with my registering system. The problem is that nothing I get with cache_get_row is really gotten. PHP код:
Код:
[23:40:01] NUMBER OF ROWS RETURNED : 1 [23:40:01] NAME : [23:40:01] PASSWORD (good one) : [23:40:01] SALT : [23:40:01] SALTED PASSWORD : ;dsnfkjfqshfsd [23:40:01] HASHED SALTED : A5FB83325A73B2498A74B68866F35CBB1E77B9A5D4E33F06986725B28B697FD150FF57D8CCB5C1DB6715CFBFFB0514FC0F2A624058748C0655C7F3E83FB071E8 Table structure : |
[18:16:55] [DEBUG] mysql_connect - host: "mysql2.alwaysdata.com", user: "s4t3kx_samp", database: "s4t3kx_sr", password: "****", port: 3306, autoreconnect: true, pool_size: 2 [18:16:55] [DEBUG] CMySQLHandle::Create - creating new connection.. [18:16:55] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [18:16:55] [DEBUG] CMySQLHandle::Create - connection created (id: 1) [18:16:55] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [18:16:55] [DEBUG] CMySQLConnection::Connect - connection was successful [18:16:55] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [18:16:55] [DEBUG] mysql_errno - connection: 1 [18:16:55] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [18:16:55] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [18:16:55] [DEBUG] CMySQLConnection::Connect - connection was successful [18:16:55] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [18:16:55] [DEBUG] CMySQLConnection::Connect - connection was successful [18:16:55] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [18:16:55] [DEBUG] CMySQLConnection::Connect - connection was successful [18:16:55] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [18:17:26] [DEBUG] mysql_format - connection: 1, len: 1024, format: "SELECT `fin_inscription` FROM `sr_accounts` WHERE `pseudo` = '%s'" [18:17:26] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `fin_inscription` FROM `sr_accounts` WHERE `pseudo` = 'Ma", callback: "OnResponseSpawn", format: "i" [18:17:26] [DEBUG] CMySQLQuery::Execute[OnResponseSpawn] - starting query execution [18:17:27] [DEBUG] CMySQLQuery::Execute[OnResponseSpawn] - query was successfully executed within 22.863 milliseconds [18:17:27] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [18:17:27] [DEBUG] Calling callback "OnResponseSpawn".. [18:17:27] [DEBUG] cache_get_row_count - connection: 0 [18:17:27] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 0 [18:17:27] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "5" [18:17:27] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [18:17:29] [DEBUG] mysql_format - connection: 1, len: 1024, format: "SELECT * FROM `sr_accounts` WHERE `pseudo` = '%s' LIMIT 1" [18:17:29] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `sr_accounts` WHERE `pseudo` = 'Mark_Brooklyn' LIM", callback: "OnPlayerLogin", format: "is" [18:17:29] [DEBUG] CMySQLQuery::Execute[OnPlayerLogin] - starting query execution [18:17:29] [DEBUG] CMySQLQuery::Execute[OnPlayerLogin] - query was successfully executed within 21.932 milliseconds [18:17:29] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [18:17:29] [DEBUG] Calling callback "OnPlayerLogin".. [18:17:29] [DEBUG] cache_get_row_count - connection: 0 [18:17:29] [DEBUG] cache_get_row_count - connection: 0 [18:17:29] [DEBUG] cache_get_row - row: 0, field_idx: 1, connection: 0, max_len: 1 [18:17:29] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '1', data: "Mark_Brooklyn" [18:17:29] [DEBUG] cache_get_row - row: 0, field_idx: 2, connection: 0, max_len: 1 [18:17:29] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '2', data: "F52C9009BE0DF5A312B5537A2ECFB00BA62FE9F3DECB40F1651F6821B239312FDDE2374246B57E8D26F30053A91B926A89B0C2CF346974D4811FAE76E4712B4B" [18:17:29] [DEBUG] cache_get_row - row: 0, field_idx: 3, connection: 0, max_len: 1 [18:17:29] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '3', data: "UCXAAI132NRqmfS5VpIAmf0CDYAfneR4Bb5PCe2o1Rbb1u89bWtuPfMVJD2MBSHE3bX9AiYxGXb0GlCqVXXKAONydAP2caeffBPvVq4aTVaJ4wAL25nvVOPnSCPYZLF4" [18:17:29] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
new
accountID, name[MPN + 1];
accountID = cache_get_field_content_int(0, "id");
cache_get_field_content(0, "pseudo", name);
printf("ID: %d", accountID);
printf("Name: %s", name);
static essais, hashed[WH_LENGHT+1], actual_pass[WH_LENGHT+1], salt[WH_LENGHT+1], salted[WH_LENGHT+65];
new test[21], accID;
printf("NUMBER OF ROWS RETURNED : %d", cache_num_rows());
cache_get_row(0, 1, test, MySQL, 21);
accID = cache_get_row_int(0, 0);
printf("NAME : %s", test);
printf("ACCOUNT ID : %d", accID);
cache_get_row(0, 2, actual_pass, MySQL, WH_LENGHT+1);
cache_get_row(0, 3, salt, MySQL, WH_LENGHT+1);
strcat(salted, password);
strcat(salted, ".");
strcat(salted, salt);
whirlpool(salted, hashed, WH_LENGHT+1);
printf("PASSWORD (good one) : %s", actual_pass);
printf("SALT : %s", salt);
printf("SALTED PASSWORD : %s", salted);
printf("HASHED SALTED : %s", hashed);
[18:20:47] LAUNCHED QUERY : SELECT * FROM `sr_accounts` WHERE `pseudo` = 'Mark_Brooklyn' LIMIT 1; [18:20:47] NUMBER OF ROWS RETURNED : 1 [18:20:47] NAME : [18:20:47] ACCOUNT ID : 1 [18:20:47] PASSWORD (good one) : [18:20:47] SALT : [18:20:47] SALTED PASSWORD : something. [18:20:47] HASHED SALTED : 736CBE68DC13E3CD2B6C69DB08DA21D7618F67FCE92E378ACE1CCAF8FEB104070DE0F828ECD26E25E88C4AC2E3FC8890F4EEC9EAA9785268D974F00D1AC0B828
root@genesis-rp:~/plugin-source/mysql# make Compiling plugin.. Compiling plugin SDK.. gcc: error: libs/sdk/amx/*.c: No such file or directory gcc: fatal error: no input files compilation terminated. make: *** [compile] Error 4