X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=blobdiff_plain;f=adu.c;h=dda9fd24ccd33fa1875d0a8f2e8a33d02ba2d723;hp=787b0e899d18cb86b20c53263603bcee735ba8ec;hb=4e757d60f7642c61e09a20a2a1de442b23208966;hpb=c9621313e2699755e65d6424fd4546c33924f272 diff --git a/adu.c b/adu.c index 787b0e8..dda9fd2 100644 --- a/adu.c +++ b/adu.c @@ -1,4 +1,10 @@ -/** \file adu.c The main functions used by all modes of operation. */ +/* + * Copyright (C) 2008 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file adu.c \brief The main functions used by all modes of operation. */ #include "adu.h" #include /* readdir() */ #include @@ -106,6 +112,7 @@ static void close_dir_table(void) if (!dir_table) return; + NOTICE_LOG("closing dir table\n"); ret = osl(osl_close_table(dir_table, OSL_MARK_CLEAN)); if (ret < 0) ERROR_LOG("failed to close dir table: %s\n", adu_strerror(-ret)); @@ -146,15 +153,20 @@ static int init_signals(void) int open_dir_table(int create) { + + if (dir_table) + return 1; dir_table_desc.dir = adu_strdup(conf.database_dir_arg); if (create) { + NOTICE_LOG("creating dir table\n"); int ret = osl(osl_create_table(&dir_table_desc)); if (ret < 0) { free((char *)dir_table_desc.dir); return ret; } } + INFO_LOG("opening dir table\n"); return osl(osl_open_table(&dir_table_desc, &dir_table)); } @@ -249,6 +261,7 @@ int main(int argc, char **argv) if (ret < 0) goto out; out: + close_all_tables(); if (ret < 0) { ERROR_LOG("%s\n", adu_strerror(-ret)); return -EXIT_FAILURE;