]> source.dussan.org Git - rspamd.git/commitdiff
* Do not use values from clock_gettime for getting current time
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 5 Jun 2009 12:39:59 +0000 (16:39 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 5 Jun 2009 12:39:59 +0000 (16:39 +0400)
src/plugins/surbl.c
src/util.c
src/util.h
src/worker.c

index 4ac156f99441277474e1e21a929103aec5b1518d..87f0c5faf0c66effc77bce41b9c0bdad62003001 100644 (file)
@@ -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);
index 026cfbd230c0e703a2bcfabeed79edb6421461c1..cb2d948ecb13603c084191ab3482d01abcf9a963 100644 (file)
@@ -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);
                        }
                }
index d771e74d83628a6b42725d94ad0b0632cb176983..c6ca2c25e07fed813e0762bb7ca047581bdf34ac 100644 (file)
@@ -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
index af457591947114608a6cb5b6fb7dcf0a1115e66a..99c311e1f1fb8814dcd94956c35096ec02e1b114 100644 (file)
@@ -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;