summaryrefslogtreecommitdiff
path: root/mail/dbmail/files/patch-0006-simplify-log_query_time-duration-logic
diff options
context:
space:
mode:
Diffstat (limited to 'mail/dbmail/files/patch-0006-simplify-log_query_time-duration-logic')
-rw-r--r--mail/dbmail/files/patch-0006-simplify-log_query_time-duration-logic119
1 files changed, 0 insertions, 119 deletions
diff --git a/mail/dbmail/files/patch-0006-simplify-log_query_time-duration-logic b/mail/dbmail/files/patch-0006-simplify-log_query_time-duration-logic
deleted file mode 100644
index 55a93c49f65c..000000000000
--- a/mail/dbmail/files/patch-0006-simplify-log_query_time-duration-logic
+++ /dev/null
@@ -1,119 +0,0 @@
-From f5b73b342b4a6cae1bb15340e5da7330e29319c1 Mon Sep 17 00:00:00 2001
-From: Paul J Stevens <p.stevens@lukkien.com>
-Date: Sat, 5 Mar 2016 18:43:12 +0100
-Subject: [PATCH 06/33] simplify log_query_time duration logic
-
----
- src/dm_db.c | 16 ++++++++--------
- src/dm_misc.c | 12 ++++++++++++
- src/dm_misc.h | 2 ++
- test/check_dbmail_db.c | 27 +++++++++++++++++++++++++++
- 4 files changed, 49 insertions(+), 8 deletions(-)
-
-diff --git src/dm_db.c src/dm_db.c
-index bfe9601..429d0ae 100644
---- src/dm_db.c
-+++ src/dm_db.c
-@@ -354,14 +354,14 @@ void db_con_clear(Connection_T c)
-
- void log_query_time(char *query, struct timeval before, struct timeval after)
- {
-- double elapsed = ((double)after.tv_sec + ((double)after.tv_usec / 1000000)) - ((double)before.tv_sec + ((double)before.tv_usec / 1000000));
-- TRACE(TRACE_DATABASE, "last query took [%.3f] seconds", elapsed);
-- if (elapsed > (double)db_params.query_time_warning)
-- TRACE(TRACE_WARNING, "slow query [%s] took [%.3f] seconds", query, elapsed);
-- else if (elapsed > (double)db_params.query_time_notice)
-- TRACE(TRACE_NOTICE, "slow query [%s] took [%.3f] seconds", query, elapsed);
-- else if (elapsed > (double)db_params.query_time_info)
-- TRACE(TRACE_INFO, "slow query [%s] took [%.3f] seconds", query, elapsed);
-+ unsigned int elapsed = (unsigned int)diff_time(before, after);
-+ TRACE(TRACE_DATABASE, "last query took [%d] seconds", elapsed);
-+ if (elapsed > db_params.query_time_warning)
-+ TRACE(TRACE_WARNING, "slow query [%s] took [%d] seconds", query, elapsed);
-+ else if (elapsed > db_params.query_time_notice)
-+ TRACE(TRACE_NOTICE, "slow query [%s] took [%d] seconds", query, elapsed);
-+ else if (elapsed > db_params.query_time_info)
-+ TRACE(TRACE_INFO, "slow query [%s] took [%d] seconds", query, elapsed);
- return;
- }
-
-diff --git src/dm_misc.c src/dm_misc.c
-index 1294930..e27ef34 100644
---- src/dm_misc.c
-+++ src/dm_misc.c
-@@ -2422,4 +2422,16 @@ void uint64_free(void *data)
- mempool_push(small_pool, data, sizeof(uint64_t));
- }
-
-+/*
-+ * calculate the difference between two timeval values
-+ * as number of seconds, using default rounding
-+ */
-+int diff_time(struct timeval before, struct timeval after)
-+{
-+ int tbefore = before.tv_sec * 1000000 + before.tv_usec;
-+ int tafter = after.tv_sec * 1000000 + after.tv_usec;
-+ int tdiff = tafter - tbefore;
-+ return (int)rint((double)tdiff/1000000);
-+}
-+
-
-diff --git src/dm_misc.h src/dm_misc.h
-index a5dd04f..9660dfa 100644
---- src/dm_misc.h
-+++ src/dm_misc.h
-@@ -178,4 +178,6 @@ gchar * get_crlf_encoded_opt(const gchar *string, int dots);
- void strip_crlf(char *buffer);
- void uint64_free(void *);
-
-+int diff_time(struct timeval before, struct timeval after);
-+
- #endif
-diff --git test/check_dbmail_db.c test/check_dbmail_db.c
-index 47c34be..e6cb170 100644
---- test/check_dbmail_db.c
-+++ test/check_dbmail_db.c
-@@ -414,6 +414,32 @@ START_TEST(test_db_get_sql)
- }
- END_TEST
-
-+START_TEST(test_diff_time)
-+{
-+ struct timeval before, after;
-+ int diff;
-+
-+ before.tv_sec = 1; before.tv_usec = 0;
-+ after.tv_sec = 2; after.tv_usec = 0;
-+ diff = diff_time(before, after);
-+ fail_unless(diff == 1);
-+
-+ before.tv_sec = 1; before.tv_usec = 1000000 - 1;
-+ after.tv_sec = 2; after.tv_usec = 0;
-+ diff = diff_time(before, after);
-+ fail_unless(diff == 0);
-+
-+ before.tv_sec = 1; before.tv_usec = 500001;
-+ after.tv_sec = 2; after.tv_usec = 0;
-+ diff = diff_time(before, after);
-+ fail_unless(diff == 0);
-+
-+ before.tv_sec = 1; before.tv_usec = 499999;
-+ after.tv_sec = 2; after.tv_usec = 0;
-+ diff = diff_time(before, after);
-+ fail_unless(diff == 1);
-+}
-+END_TEST
-
- Suite *dbmail_db_suite(void)
- {
-@@ -435,6 +461,7 @@ Suite *dbmail_db_suite(void)
- tcase_add_test(tc_db, test_mailbox_match_new);
- tcase_add_test(tc_db, test_db_findmailbox_by_regex);
- tcase_add_test(tc_db, test_db_get_sql);
-+ tcase_add_test(tc_db, test_diff_time);
-
- return s;
- }
---
-2.10.1 (Apple Git-78)
-