diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-22 17:39:03 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-22 17:39:03 +0400 |
commit | e9d2ad6a1b942cb5bbba9a268cc7e0108a0145ea (patch) | |
tree | a22232f181b0b6e0af3056869c666578fa30c0c0 /src/symbols_cache.c | |
parent | d81433607b87acf08bab4ccb5a01f1c992dfb8bb (diff) | |
download | rspamd-e9d2ad6a1b942cb5bbba9a268cc7e0108a0145ea.tar.gz rspamd-e9d2ad6a1b942cb5bbba9a268cc7e0108a0145ea.zip |
* Rewrite buffered input for line policy (again)
* Fix issue with links that are ip addresses in numeric form in surbl
* On Darwin use BSD style sendfile definition
* Reorganize platform specific knobs in CMakeLists
* Use gettimeofday on systems that have not clock_getres
* Use ftime for dns trans id generation on systems without clock_getres
Diffstat (limited to 'src/symbols_cache.c')
-rw-r--r-- | src/symbols_cache.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/symbols_cache.c b/src/symbols_cache.c index 046d2f6d7..f24380f28 100644 --- a/src/symbols_cache.c +++ b/src/symbols_cache.c @@ -596,7 +596,11 @@ struct symbol_callback_data { gboolean call_symbol_callback (struct worker_task * task, struct symbols_cache * cache, gpointer *save) { +#ifdef HAVE_CLOCK_GETTIME struct timespec ts1, ts2; +#else + struct timeval tv1, tv2; +#endif uint64_t diff; struct cache_item *item = NULL; struct symbol_callback_data *s = *save; @@ -753,24 +757,40 @@ call_symbol_callback (struct worker_task * task, struct symbols_cache * cache, g return FALSE; } if (check_view (task->cfg->views, item->s->symbol, task)) { -#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID +#ifdef HAVE_CLOCK_GETTIME +# ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts1); -#elif defined(HAVE_CLOCK_VIRTUAL) +# elif defined(HAVE_CLOCK_VIRTUAL) clock_gettime (CLOCK_VIRTUAL, &ts1); -#else +# else clock_gettime (CLOCK_REALTIME, &ts1); +# endif +#else + if (gettimeofday (&tv1, NULL) == -1) { + msg_warn ("gettimeofday failed: %s", strerror (errno)); + } #endif item->func (task, item->user_data); -#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID +#ifdef HAVE_CLOCK_GETTIME +# ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts2); -#elif defined(HAVE_CLOCK_VIRTUAL) +# elif defined(HAVE_CLOCK_VIRTUAL) clock_gettime (CLOCK_VIRTUAL, &ts2); -#else +# else clock_gettime (CLOCK_REALTIME, &ts2); +# endif +#else + if (gettimeofday (&tv2, NULL) == -1) { + msg_warn ("gettimeofday failed: %s", strerror (errno)); + } #endif +#ifdef HAVE_CLOCK_GETTIME diff = (ts2.tv_sec - ts1.tv_sec) * 1000000 + (ts2.tv_nsec - ts1.tv_nsec) / 1000; +#else + diff = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec); +#endif item->s->avg_time = set_counter (item->s->symbol, diff); } |