30.04.2011, 17:13
ok, i think this is problem, for me exemple, it is... lets show you some test code:
first i run MySQL server
and then run samp-server with this test code:
and every second public CheckAlive print this result:
so i decided to shut down MySQL server and i want samp-server still ON, but samp server crashed when first time function CheckAlive is called after shuting down MySQL, it doesnt return anything with mysql_ping(),
code from debug:
What i want to show you, it that thing is stupid, lets say that i have forum and server on same machine, and i dont want to turn off my samp server, but i want only in few second to restart my mysql server becasue that i need for forum, and for that i need function for samp server to check if mysql connection is alive, if not that not allow people to login... i can check only with mysql_ping but if mysql server is down that will crash server...
but other strange thing is if i call mysql_ping before mysql_connect and there is no connection it will not crash server...
so what do you think abouth this?
I think that mysql_ping is stupid native function, why this function cannot check connection with database even if mysql server is down!?
first i run MySQL server
and then run samp-server with this test code:
Код:
public OnGameModeInit() { mysql_debug( 1 ); mysql_connect("******", "******","***********", "***********"); if(mysql_ping() == 1) prinft("Connection with database is alive!"); SetTimer("CheckAlive",1000,true); return 1; } forward CheckAlive(); public CheckAlive() { printf("Connection ping: %d", mysql_ping()); return 1; }
Quote:
Connection ping: 1 |
code from debug:
Код:
[18:53:41] >> mysql_connect( ) [18:53:41] CMySQLHandler::CMySQLHandler() - constructor called. [18:53:41] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "ahoh_3022" | Username: "ahoh_3022" ... [18:53:41] CMySQLHandler::Connect() - Connection was successful. [18:53:41] CMySQLHandler::Connect() - Auto-Reconnect has been enabled. [18:53:41] >> mysql_ping( Connection handle: 1 ) [18:53:42] CMySQLHandler::Ping() - Connection is still alive. [18:53:43] >> mysql_ping( Connection handle: 1 ) [18:53:44] CMySQLHandler::Ping() - Connection is still alive. [18:53:45] >> mysql_ping( Connection handle: 1 ) [18:53:46] CMySQLHandler::Ping() - Connection is still alive. [18:53:47] >> mysql_ping( Connection handle: 1 ) [18:53:48] CMySQLHandler::Ping() - Connection is still alive. [18:53:49] >> mysql_ping( Connection handle: 1 ) [18:53:50] CMySQLHandler::Ping() - Connection is still alive. [18:53:51] >> mysql_ping( Connection handle: 1 ) [18:53:52] CMySQLHandler::Ping() - Connection is still alive. //in this moment i have turn off mysql server!!!!!!!!!! [18:53:47] >> mysql_ping( Connection handle: 1 )
but other strange thing is if i call mysql_ping before mysql_connect and there is no connection it will not crash server...
so what do you think abouth this?
I think that mysql_ping is stupid native function, why this function cannot check connection with database even if mysql server is down!?