From: Florent Bruneau Date: Mon, 10 Nov 2008 22:43:34 +0000 (+0100) Subject: Cleanup start/refresh. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=8950d42993b7148718f712b8d7e77aaa21ef14ce;p=apps%2Fpfixtools.git Cleanup start/refresh. Signed-off-by: Florent Bruneau --- diff --git a/postlicyd/greylist.c b/postlicyd/greylist.c index 7d4f282..1a7d68e 100644 --- a/postlicyd/greylist.c +++ b/postlicyd/greylist.c @@ -151,7 +151,7 @@ static TCBDB **greylist_db_get(const greylist_config_t *config, const char *path } } if (!greylist_db_need_cleanup(config, awl_db) || config->max_age <= 0) { - info("no cleanup needed"); + info("%s loaded: no cleanup needed", path); res->db = awl_db; return &res->db; } else { @@ -193,7 +193,6 @@ static TCBDB **greylist_db_get(const greylist_config_t *config, const char *path } ++old_count; } while (tcbdbcurnext(cur)); - now = time(0); tcbdbput(tmp_db, "@@cleanup@@", strlen("@@cleanup@@"), &now, sizeof(now)); } tcxstrdel(key); @@ -215,11 +214,11 @@ static TCBDB **greylist_db_get(const greylist_config_t *config, const char *path /** Cleanup successful, replace the old database with the new one. */ if (trashable) { - info("database cleanup finished: database was corrupted, create a new one"); + info("%s cleanup: database was corrupted, create a new one", path); unlink(path); } else if (replace) { - info("database cleanup finished: before %u entries, after %d entries", - old_count, new_count); + info("%s cleanup: done in %us, before %u, after %u entries", + path, (uint32_t)(time(0) - now), old_count, new_count); unlink(path); if (rename(tmppath, path) != 0) { UNIXERR("rename"); @@ -228,7 +227,8 @@ static TCBDB **greylist_db_get(const greylist_config_t *config, const char *path } } else { unlink(tmppath); - info("database cleanup finished: nothing to do, %u entries", new_count); + info("%s cleanup: done in %us, nothing to do, %u entries", + path, (uint32_t)(time(0) - now), old_count); } } @@ -243,6 +243,7 @@ static TCBDB **greylist_db_get(const greylist_config_t *config, const char *path return NULL; } + info("%s loaded", path); res->db = awl_db; return &res->db; } @@ -255,7 +256,6 @@ static bool greylist_initialize(greylist_config_t *config, if (config->client_awl) { snprintf(path, sizeof(path), "%s/%swhitelist.db", directory, prefix); - info("loading auto-whitelist database"); config->awl_db = greylist_db_get(config, path, sizeof(struct awl_entry), (db_entry_checker_t)(greylist_check_awlentry)); @@ -266,7 +266,6 @@ static bool greylist_initialize(greylist_config_t *config, } snprintf(path, sizeof(path), "%s/%sgreylist.db", directory, prefix); - info("loading greylist database"); config->obj_db = greylist_db_get(config, path, sizeof(struct obj_entry), (db_entry_checker_t)(greylist_check_object)); diff --git a/postlicyd/iplist.c b/postlicyd/iplist.c index b37d64b..353dc08 100644 --- a/postlicyd/iplist.c +++ b/postlicyd/iplist.c @@ -140,6 +140,7 @@ rbldb_t *rbldb_create(const char *file, bool lock) file_map_t map; const char *p, *end; uint32_t ips = 0; + time_t now = time(0); if (!file_map_open(&map, file, false)) { return NULL; @@ -147,7 +148,6 @@ rbldb_t *rbldb_create(const char *file, bool lock) rbldb_resource_t *res = resource_get("iplist", file); if (res == NULL) { - debug("No resource found"); res = p_new(rbldb_resource_t, 1); resource_set("iplist", file, res, (resource_destructor_t)rbldb_resource_wipe); } @@ -156,11 +156,10 @@ rbldb_t *rbldb_create(const char *file, bool lock) db->filename = m_strdup(file); db->ips = res->ips; if (map.st.st_size == res->size && map.st.st_mtime == res->mtime) { - info("rbl %s up to date", file); + info("%s loaded: already up-to-date", file); file_map_close(&map); return db; } - debug("mtime %d/%d, size %d/%d", (int)map.st.st_mtime, (int)res->mtime, (int)map.st.st_size, (int)res->size); res->size = map.st.st_size; res->mtime = map.st.st_mtime; @@ -170,8 +169,7 @@ rbldb_t *rbldb_create(const char *file, bool lock) --end; } if (end != map.end) { - warn("file %s miss a final \\n, ignoring last line", - file); + warn("%s: final \\n missing, ignoring last line", file); } while (p < end) { @@ -205,7 +203,7 @@ rbldb_t *rbldb_create(const char *file, bool lock) } } - info("rbl %s loaded, %d IPs", file, ips); + info("%s loaded: done in %us, %u IPs", file, (uint32_t)(time(0) - now), ips); return db; } diff --git a/postlicyd/main-postlicyd.c b/postlicyd/main-postlicyd.c index c60d515..dab0bf0 100644 --- a/postlicyd/main-postlicyd.c +++ b/postlicyd/main-postlicyd.c @@ -83,7 +83,10 @@ static bool config_refresh(void *mconfig) if (filter_running > 0) { return true; } + log_state = "refreshing "; + info("reloading configuration"); bool ret = config_reload(mconfig); + log_state = ""; foreach (client_t **server, busy) { client_io_ro(*server); }} diff --git a/postlicyd/strlist.c b/postlicyd/strlist.c index 29fe79e..e8202ff 100644 --- a/postlicyd/strlist.c +++ b/postlicyd/strlist.c @@ -147,6 +147,7 @@ static bool strlist_create(strlist_local_t *local, const char *p, *end; char line[BUFSIZ]; uint32_t count = 0; + time_t now = time(0); if (!file_map_open(&map, file, false)) { return false; @@ -157,8 +158,7 @@ static bool strlist_create(strlist_local_t *local, --end; } if (end != map.end) { - warn("file %s miss a final \\n, ignoring last line", - file); + warn("%s: final \\n missing, ignoring last line", file); } strlist_resource_t *res = resource_get("strlist", file); @@ -166,8 +166,7 @@ static bool strlist_create(strlist_local_t *local, res = p_new(strlist_resource_t, 1); resource_set("strlist", file, res, (resource_destructor_t)strlist_resource_wipe); } else if (res->trie2 != NULL) { - err("A file (%s) cannot be used as a rbldns zone file and a strlist file at the same time", - file); + err("%s not loaded: the file is already used as a rbldns zone file", file); resource_release("strlist", file); file_map_close(&map); return false; @@ -180,7 +179,7 @@ static bool strlist_create(strlist_local_t *local, local->reverse = reverse; local->partial = partial; if (res->size == map.st.st_size && res->mtime == map.st.st_mtime) { - info("strlist %s up to date", file); + info("%s loaded: already up-to-date", file); file_map_close(&map); return true; } @@ -195,7 +194,7 @@ static bool strlist_create(strlist_local_t *local, eol = end; } if (eol - p >= BUFSIZ) { - err("unreasonnable long line"); + err("%s not loaded: unreasonnable long line", file); file_map_close(&map); trie_delete(&res->trie1); strlist_local_wipe(local); @@ -219,7 +218,7 @@ static bool strlist_create(strlist_local_t *local, } file_map_close(&map); trie_compile(res->trie1, lock); - info("%s loaded, %u entries", file, count); + info("%s loaded: done in %us, %u entries", file, (uint32_t)(time(0) - now), count); return true; } @@ -230,6 +229,7 @@ static bool strlist_create_from_rhbl(strlist_local_t *hosts, strlist_local_t *do file_map_t map; const char *p, *end; char line[BUFSIZ]; + time_t now = time(0); if (!file_map_open(&map, file, false)) { return false; @@ -240,8 +240,7 @@ static bool strlist_create_from_rhbl(strlist_local_t *hosts, strlist_local_t *do --end; } if (end != map.end) { - warn("file %s miss a final \\n, ignoring last line", - file); + warn("%s: final \\n missing, ignoring last line", file); } @@ -250,8 +249,7 @@ static bool strlist_create_from_rhbl(strlist_local_t *hosts, strlist_local_t *do res = p_new(strlist_resource_t, 1); resource_set("strlist", file, res, (resource_destructor_t)strlist_resource_wipe); } else if (res->trie2 == NULL) { - err("A file (%s) cannot be used as a rbldns zone file and a strlist file at the same time", - file); + err("%s not loaded: the file is already used as a strlist-file parameter", file); resource_release("strlist", file); file_map_close(&map); return false; @@ -273,7 +271,7 @@ static bool strlist_create_from_rhbl(strlist_local_t *hosts, strlist_local_t *do domain_count = 0; if (map.st.st_size == res->size && map.st.st_mtime == res->mtime) { - info("rbldns %s up to date", file); + info("%s loaded: already up-to-date", file); file_map_close(&map); return true; } @@ -291,7 +289,7 @@ static bool strlist_create_from_rhbl(strlist_local_t *hosts, strlist_local_t *do eol = end; } if (eol - p >= BUFSIZ) { - err("unreasonnable long line"); + err("%s not loaded: unreasonnable long line", file); file_map_close(&map); trie_delete(&res->trie1); trie_delete(&res->trie2); @@ -332,11 +330,13 @@ static bool strlist_create_from_rhbl(strlist_local_t *hosts, strlist_local_t *do } else { trie_delete(&res->trie2); } - info("rhbl %s loaded, %u hosts, %u domains", file, host_count, domain_count); if (res->trie1 == NULL && res->trie2 == NULL) { + err("%s not loaded: no data found", file); strlist_local_wipe(hosts); return false; } + info("%s loaded: done in %us, %u hosts, %u domains", file, + (uint32_t)(time(0) - now), host_count, domain_count); return true; }