From: Vsevolod Stakhov Date: Fri, 5 Jun 2009 12:39:59 +0000 (+0400) Subject: * Do not use values from clock_gettime for getting current time X-Git-Tag: 0.2.7~127 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3cd423a9d825d10c2e0390a2a35a5f99a1f74127;p=rspamd.git * Do not use values from clock_gettime for getting current time --- diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 4ac156f99..87f0c5faf 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -658,10 +658,10 @@ surbl_test_url (struct worker_task *task) /* Try to check lists */ if (surbl_module_ctx->tld2_file) { - maybe_parse_host_list (surbl_module_ctx->surbl_pool, surbl_module_ctx->tld2, surbl_module_ctx->tld2_file, task->ts.tv_sec); + maybe_parse_host_list (surbl_module_ctx->surbl_pool, surbl_module_ctx->tld2, surbl_module_ctx->tld2_file); } if (surbl_module_ctx->whitelist_file) { - maybe_parse_host_list (surbl_module_ctx->surbl_pool, surbl_module_ctx->whitelist, surbl_module_ctx->whitelist_file, task->ts.tv_sec); + maybe_parse_host_list (surbl_module_ctx->surbl_pool, surbl_module_ctx->whitelist, surbl_module_ctx->whitelist_file); } url_tree = g_tree_new ((GCompareFunc)g_ascii_strcasecmp); diff --git a/src/util.c b/src/util.c index 026cfbd23..cb2d948ec 100644 --- a/src/util.c +++ b/src/util.c @@ -936,22 +936,24 @@ parse_host_list (memory_pool_t *pool, GHashTable *tbl, const char *filename) } gboolean -maybe_parse_host_list (memory_pool_t *pool, GHashTable *tbl, const char *filename, time_t tv) +maybe_parse_host_list (memory_pool_t *pool, GHashTable *tbl, const char *filename) { struct list_file *lf; struct stat cur_st; + time_t cur_time = time (NULL); if (listfiles == NULL || (lf = g_hash_table_lookup (listfiles, filename)) == NULL) { /* Do not try to parse unknown files */ return FALSE; } - if (tv - lf->st.st_mtime > MON_TIMEOUT) { + if (cur_time - lf->st.st_mtime > MON_TIMEOUT) { /* Try to stat */ if (stat (lf->filename, &cur_st) != -1) { if (cur_st.st_mtime > lf->st.st_mtime) { g_hash_table_remove (listfiles, lf->filename); g_hash_table_remove_all (tbl); + msg_info ("maybe_parse_host_list: file %s was modified and rereaded", filename); return parse_host_list (pool, tbl, filename); } } diff --git a/src/util.h b/src/util.h index d771e74d8..c6ca2c25e 100644 --- a/src/util.h +++ b/src/util.h @@ -60,7 +60,7 @@ const char* calculate_check_time (struct timespec *begin, int resolution); void set_counter (const char *name, long int value); gboolean parse_host_list (memory_pool_t *pool, GHashTable *tbl, const char *filename); -gboolean maybe_parse_host_list (memory_pool_t *pool, GHashTable *tbl, const char *filename, time_t tv); +gboolean maybe_parse_host_list (memory_pool_t *pool, GHashTable *tbl, const char *filename); #endif diff --git a/src/worker.c b/src/worker.c index af4575919..99c311e1f 100644 --- a/src/worker.c +++ b/src/worker.c @@ -254,7 +254,7 @@ accept_socket (int fd, short what, void *arg) struct worker_task *new_task; socklen_t addrlen = sizeof(ss); int nfd; - + if ((nfd = accept_from_socket (fd, (struct sockaddr *)&ss, &addrlen)) == -1) { msg_warn ("accept_socket: accept failed: %s", strerror (errno)); return;