bmsd/mysql.c

changeset 852
71f0fa38b634
parent 849
16079aef4c4c
equal deleted inserted replaced
851:b15fa90a9af5 852:71f0fa38b634
72 if (con == NULL) { 72 if (con == NULL) {
73 syslog(LOG_NOTICE, "MySQL: mysql_init() failed"); 73 syslog(LOG_NOTICE, "MySQL: mysql_init() failed");
74 return 1; 74 return 1;
75 } 75 }
76 76
77 mysql_options(con, MYSQL_OPT_RECONNECT, &reconnect);
78
79 if (mysql_real_connect(con, Config.mysql_host, Config.mysql_user, Config.mysql_pass, Config.mysql_database, Config.mysql_port, NULL, 0) == NULL) { 77 if (mysql_real_connect(con, Config.mysql_host, Config.mysql_user, Config.mysql_pass, Config.mysql_database, Config.mysql_port, NULL, 0) == NULL) {
80 syslog(LOG_NOTICE, "MySQL: mysql_real_connect() %s", mysql_error(con)); 78 syslog(LOG_NOTICE, "MySQL: mysql_real_connect() %s", mysql_error(con));
81 return 2; 79 return 2;
82 } 80 }
81
82 mysql_optionsv(con, MYSQL_OPT_RECONNECT, (void *)&reconnect);
83 83
84 syslog(LOG_NOTICE, "MySQL: connected to %s:%d database %s", Config.mysql_host, Config.mysql_port, Config.mysql_database); 84 syslog(LOG_NOTICE, "MySQL: connected to %s:%d database %s", Config.mysql_host, Config.mysql_port, Config.mysql_database);
85 syslog(LOG_NOTICE, "MySQL: %s server info: %s", mysql_get_host_info(con), mysql_get_server_info(con)); 85 syslog(LOG_NOTICE, "MySQL: %s server info: %s", mysql_get_host_info(con), mysql_get_server_info(con));
86 if (debug) 86 if (debug)
87 fprintf(stdout, "MySQL: connected\n"); 87 fprintf(stdout, "MySQL: connected\n");

mercurial