This avoids unnecessarily trying to connect to failing connections.
if (conns[idx].host_idx == unwanted_host_idx)
continue;
- if (!SQL_DB_IS_READY(conndb)) {
+ if (!SQL_DB_IS_READY(conndb) && conndb->to_reconnect == NULL) {
/* see if we could reconnect to it immediately */
(void)sql_connect(conndb);
}
int ret = -1, ret2;
array_foreach(&db->all_connections, conn) {
- ret2 = sql_connect(conn->db);
+ ret2 = conn->db->to_reconnect != NULL ? -1 :
+ sql_connect(conn->db);
if (ret2 > 0)
return 1;
if (ret2 == 0)