--- src/nsvsd/nsvsd.c 2007-04-07 16:43:32.000000000 -0700 +++ src/nsvsd/nsvsd.c 2008-10-24 12:00:25.000000000 -0700 @@ -188,7 +188,13 @@ /* Run the query */ if (mysql_query (&connections[th_num].mysql, query)) { - nsvs_log (LOG_ALERT, "%s (%d): mysql_query: %s", __FUNCTION__, th_num, + /* Reconnect did not happen/work, run the query again. */ + if (mysql_errno (&connections[th_num].mysql) == 2013) { + nsvs_log (LOG_ALERT, "%s (%d): mysql_query: %s, retrying...", __FUNCTION__, th_num, + mysql_error (&connections[th_num].mysql)); + return run_query(type, key, th_num); + } + nsvs_log (LOG_ALERT, "%s (%d): mysql_query: %s, failed...", __FUNCTION__, th_num, mysql_error (&connections[th_num].mysql)); return 0; }