cd->log_buf[--cd->log_offset] = '\0';
}
-#ifdef HAVE_CLOCK_GETTIME
cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset,
cd->log_size - cd->log_offset,
"]), len: %z, time: %s,",
task->msg.len,
- calculate_check_time (&task->tv, &task->ts, task->cfg->clock_res,
- &task->scan_milliseconds));
-#else
- cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset,
- cd->log_size - cd->log_offset,
- "]), len: %z, time: %s,",
- task->msg.len,
- calculate_check_time (&task->tv, task->cfg->clock_res,
- &task->scan_milliseconds));
-#endif
+ calculate_check_time (task->time_real, task->time_virtual,
+ task->cfg->clock_res,
+ &task->scan_milliseconds));
}
gboolean
logbuf->len--;
}
-#ifdef HAVE_CLOCK_GETTIME
- rspamd_printf_gstring (logbuf, "]), len: %z, time: %s, dns req: %d,",
- task->msg.len, calculate_check_time (&task->tv, &task->ts,
- task->cfg->clock_res, &task->scan_milliseconds),
- task->dns_requests);
-#else
rspamd_printf_gstring (logbuf, "]), len: %z, time: %s, dns req: %d,",
task->msg.len,
- calculate_check_time (&task->tv, task->cfg->clock_res,
+ calculate_check_time (task->time_real,
+ task->time_virtual,
+ task->cfg->clock_res,
&task->scan_milliseconds),
- task->dns_requests);
-#endif
+ task->dns_requests);
}
return obj;
struct symbols_cache * cache,
gpointer *save)
{
-#ifdef HAVE_CLOCK_GETTIME
- struct timespec ts1, ts2;
-#else
- struct timeval tv1, tv2;
-#endif
+ double t1, t2;
guint64 diff;
struct cache_item *item = NULL;
struct symbol_callback_data *s = *save;
return FALSE;
}
if (!item->is_virtual && !item->is_skipped) {
-#ifdef HAVE_CLOCK_GETTIME
-# ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts1);
-# elif defined(HAVE_CLOCK_VIRTUAL)
- clock_gettime (CLOCK_VIRTUAL, &ts1);
-# else
- clock_gettime (CLOCK_REALTIME, &ts1);
-# endif
-#else
- if (gettimeofday (&tv1, NULL) == -1) {
- msg_warn ("gettimeofday failed: %s", strerror (errno));
- }
-#endif
+ t1 = rspamd_get_ticks ();
+
if (G_UNLIKELY (check_debug_symbol (task->cfg, item->s->symbol))) {
rspamd_log_debug (rspamd_main->logger);
item->func (task, item->user_data);
item->func (task, item->user_data);
}
+ t2 = rspamd_get_ticks ();
-#ifdef HAVE_CLOCK_GETTIME
-# ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts2);
-# elif defined(HAVE_CLOCK_VIRTUAL)
- clock_gettime (CLOCK_VIRTUAL, &ts2);
-# 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
+ diff = (t2 - t1) * 1000000;
item->s->avg_time = rspamd_set_counter (item, diff);
}
new_task->flags |= RSPAMD_TASK_FLAG_PASS_ALL;
}
}
-#ifdef HAVE_CLOCK_GETTIME
-# ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &new_task->ts);
-# elif defined(HAVE_CLOCK_VIRTUAL)
- clock_gettime (CLOCK_VIRTUAL, &new_task->ts);
-# else
- clock_gettime (CLOCK_REALTIME, &new_task->ts);
-# endif
-#endif
- if (gettimeofday (&new_task->tv, NULL) == -1) {
- msg_warn ("gettimeofday failed: %s", strerror (errno));
- }
+
+ gettimeofday (&new_task->tv, NULL);
+ new_task->time_real = rspamd_get_ticks ();
+ new_task->time_virtual = rspamd_get_virtual_ticks ();
new_task->task_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
gchar *last_error; /**< last error */
gint error_code; /**< code of last error */
rspamd_mempool_t *task_pool; /**< memory pool for task */
-#ifdef HAVE_CLOCK_GETTIME
- struct timespec ts; /**< time of connection */
-#endif
- struct timeval tv; /**< time of connection */
+ double time_real;
+ double time_virtual;
+ struct timeval tv;
guint32 scan_milliseconds; /**< how much milliseconds passed */
guint32 parser_recursion; /**< for avoiding recursion stack overflow */
gboolean (*fin_callback)(struct rspamd_task *task, void *arg); /**< calback for filters finalizing */