diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-05 17:48:20 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-05 17:48:20 +0400 |
commit | 52e71f9ed43b0e0f7f030eb0f0b56a887978cf8a (patch) | |
tree | 9496a3ea6f3b95006554b003e01425e6b68b2765 /src/util.c | |
parent | bae637bec8e9c23668cbacbb9f5a1bd829cae487 (diff) | |
download | rspamd-52e71f9ed43b0e0f7f030eb0f0b56a887978cf8a.tar.gz rspamd-52e71f9ed43b0e0f7f030eb0f0b56a887978cf8a.zip |
* Fix detection of numeric urls (reported by citrin)
* Write real time of message's scan to log (not only virtual)
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/util.c b/src/util.c index 9a82a25f6..dc8569cdf 100644 --- a/src/util.c +++ b/src/util.c @@ -778,18 +778,24 @@ resolve_stat_filename (memory_pool_t * pool, char *pattern, char *rcpt, char *fr #ifdef HAVE_CLOCK_GETTIME const char * -calculate_check_time (struct timespec *begin, int resolution) +calculate_check_time (struct timeval *tv, struct timespec *begin, int resolution) #else const char * calculate_check_time (struct timeval *begin, int resolution) #endif { - double diff; - static char res[sizeof ("100000.000")]; - static char fmt[sizeof ("%.10f")]; + double vdiff, diff; + static char res[64]; + static char fmt[sizeof ("%.10f ms real, %.10f ms virtual")]; + struct timeval tv_now; + if (gettimeofday (&tv_now, NULL) == -1) { + msg_warn ("gettimeofday failed: %s", strerror (errno)); + } #ifdef HAVE_CLOCK_GETTIME struct timespec ts; + diff = (tv_now.tv_sec - tv->tv_sec) * 1000. + /* Seconds */ + (tv_now.tv_usec - tv->tv_usec) / 1000.; /* Microseconds */ #ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts); #elif defined(HAVE_CLOCK_VIRTUAL) @@ -798,20 +804,17 @@ calculate_check_time (struct timeval *begin, int resolution) clock_gettime (CLOCK_REALTIME, &ts); #endif - diff = (ts.tv_sec - begin->tv_sec) * 1000. + /* Seconds */ + vdiff = (ts.tv_sec - begin->tv_sec) * 1000. + /* Seconds */ (ts.tv_nsec - begin->tv_nsec) / 1000000.; /* Nanoseconds */ #else - struct timeval tv; + diff = (tv_now.tv_sec - begin->tv_sec) * 1000. + /* Seconds */ + (tv_now.tv_usec - begin->tv_usec) / 1000.; /* Microseconds */ - 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 */ + vdiff = diff; #endif - sprintf (fmt, "%%.%df", resolution); - snprintf (res, sizeof (res), fmt, diff); + sprintf (fmt, "%%.%dfms real, %%.%dfms virtual", resolution, resolution); + snprintf (res, sizeof (res), fmt, diff, vdiff); return (const char *)res; } |