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/util.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/util.c')
-rw-r--r-- | src/util.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c index 9ab0820f0..7e9aeb463 100644 --- a/src/util.c +++ b/src/util.c @@ -769,13 +769,19 @@ resolve_stat_filename (memory_pool_t * pool, char *pattern, char *rcpt, char *fr return new; } +#ifdef HAVE_CLOCK_GETTIME const char * calculate_check_time (struct timespec *begin, int resolution) +#else +const char * +calculate_check_time (struct timeval *begin, int resolution) +#endif { - struct timespec ts; double diff; static char res[sizeof ("100000.000")]; static char fmt[sizeof ("%.10f")]; +#ifdef HAVE_CLOCK_GETTIME + struct timespec ts; #ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts); @@ -787,6 +793,16 @@ calculate_check_time (struct timespec *begin, int resolution) diff = (ts.tv_sec - begin->tv_sec) * 1000. + /* Seconds */ (ts.tv_nsec - begin->tv_nsec) / 1000000.; /* Nanoseconds */ +#else + struct timeval tv; + + if (gettimeofday (&tv, NULL) == -1) { + msg_warn ("gettimeofday failed: %s", strerror (errno)); + } + diff = (tv.tv_sec - begin->tv_sec) * 1000. + /* Seconds */ + (tv.tv_usec - begin->tv_usec) / 1000.; /* Microseconds */ +#endif + sprintf (fmt, "%%.%df", resolution); snprintf (res, sizeof (res), fmt, diff); |