G-WAN和持久的MySQL连接 [英] G-WAN and persistent MySQL connexion
本文介绍了G-WAN和持久的MySQL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我再次遇到有关G-WAN和MySQL的疑问.
me again with a little question about G-WAN and MySQL.
下面的脚本工作正常... 我唯一的问题是MySQL何时崩溃. G-WAN脚本崩溃以及G-WAN也是如此.
This script below works fine ... My only problem is when MySQL went down. G-WAN script crash and G-WAN as well.
保持持久的MySQL连接并处理MySQL停机的嵌套方法是什么?
What is the nest way to keep a persistent MySQL connexion and handle MySQL downtime?
typedef struct {
MYSQL *conn;
} data_t;
int main(int argc, char *argv[])
{
u64 start = getus();
data_t **data = (data_t**)get_env(argv, US_SERVER_DATA);
xbuf_t *reply = get_reply(argv);
if(!data[0]) // first time: persistent pointer is uninitialized
{
data[0] = (data_t*)calloc(1, sizeof(data_t));
if(!data[0])
return 500; // out of memory
data[0]->conn = (MYSQL *)mysql_init(data[0]->conn);
if(! data[0]->conn) {
xbuf_xcat(reply, "MySQL Error");
return(200);
}
if(! mysql_real_connect(data[0]->conn, "localhost", "root", "willow", "test", NULL, NULL, 0)) {
return 500;
}
xbuf_cat(reply, "initialized data<br>");
}
// Do what we want here ...
推荐答案
如果您在提出问题之前进行一些研究,那就太好了……
It be great if You do a bit of research before asking a question...
请参阅-> http://dev.mysql.com/doc/refman/5.5/en/mysql-ping.html
这篇关于G-WAN和持久的MySQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文