mysql_ping return "Lost connect while query" when mysql server still alive after 32768 seconds
I report it as a bug(see:
http://bugs.mysql.com/bug.php?id=13303&error=bc) but they tell me "can't repeat". But I repeat it again, again and again on different version mysql, like 5.0.11, 5.0.12.
I know that after 5.0.3 version that something changed, as the document says: "mysql_real_connect() sets the reconnect flag (part of the MYSQL structure) to a value of 1 in versions of the API strictly older than 5.0.3, of 0 in newer versions."
So I set mysql.reconnect as 1 after msyql_real_connect. But it repeat again!
Between testing, I use ethereal to get the mysql package, after 32768 seconds, I find only 2 packs like this:
from -> to context
1st client->mysql server mysql command:Ping
2nd mysql server->client RST HEX is: 0c ea 97 85 a1 0a 7f 8a 00 00 00 00 50 04 00 00 ec d9 00 00
I can't find any packs that want to reconnect to mysql server
below is my codes that initial mysql connect:
int msi_init(char *hostname, char *dbname, char *username, char
*passwd)
{
unsigned int timeout=60;
if(hostname==NULL || dbname==NULL || username==NULL ||
passwd==NULL) return -1;
if(mysql_init(&mysql)==NULL) return -2;
if(!mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&timeout))
printf("set timeout as 60 seconds success\n");
else
printf("set timeout as 60 seconds fail\n");
if(!mysql_real_connect(&mysql, hostname, username, passwd,
dbname, 0, NULL, CLIENT_MULTI_RESULTS))
{
mysql_close(&mysql);
return -3;
}
printf("reconnect flag=%d\n", mysql.reconnect);
mysql.reconnect=1;
printf("after setting, reconnect flag=%d\n", mysql.reconnect);
return 0;
}
that's all.