Skip to content

Commit

Permalink
Fix some bugs in non supported sql pooling code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed May 5, 2013
1 parent 007a5ce commit 28c0060
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/cats/sql_pooling.c
Expand Up @@ -118,9 +118,6 @@ static void destroy_pool_descriptor(SQL_POOL_DESCRIPTOR *spd, bool flush_only)
db_pooling_descriptors->remove(spd);
delete spd->pool_entries;
free(spd);
} else {
delete spd->pool_entries;
spd->pool_entries = NULL;
}
}

Expand Down Expand Up @@ -695,6 +692,10 @@ void db_sql_close_pooled_connection(JCR *jcr, B_DB *mdb, bool abort)
*/
now = time(NULL);
foreach_dlist(spd, db_pooling_descriptors) {
if (!spd->pool_entries) {
continue;
}

foreach_dlist(spe, spd->pool_entries) {
if (spe->db_handle == mdb) {
found = true;
Expand Down Expand Up @@ -737,7 +738,11 @@ void db_sql_close_pooled_connection(JCR *jcr, B_DB *mdb, bool abort)
free(spe);
spd->nr_connections--;
}
goto ok_out;

/*
* No need to search further if we found the item we were looking for.
*/
break;
}
}

Expand All @@ -758,6 +763,13 @@ void db_sql_close_pooled_connection(JCR *jcr, B_DB *mdb, bool abort)
sql_pool_shrink(spd);
}
}

/*
* No need to search further if we found the item we were looking for.
*/
if (found) {
break;
}
}

/*
Expand All @@ -768,7 +780,6 @@ void db_sql_close_pooled_connection(JCR *jcr, B_DB *mdb, bool abort)
db_close_database(jcr, mdb);
}

ok_out:
V(mutex);
}

Expand Down
2 changes: 1 addition & 1 deletion src/dird/dird.c
Expand Up @@ -543,7 +543,7 @@ void reload_config(int sig)
ok = parse_dir_config(config, configfile, M_ERROR);

Dmsg0(100, "Reloaded config file\n");
if (!ok || !check_resources() || !check_catalog(UPDATE_CATALOG)) {
if (!ok || !check_resources() || !check_catalog(UPDATE_CATALOG) || !initialize_sql_pooling()) {
rtable = find_free_reload_table_entry(); /* save new, bad table */
if (rtable < 0) {
Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
Expand Down

0 comments on commit 28c0060

Please sign in to comment.