]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] millisecond granularity for statschannel timers
authorEvan Hunt <each@isc.org>
Thu, 7 Jan 2016 23:34:14 +0000 (15:34 -0800)
committerEvan Hunt <each@isc.org>
Thu, 7 Jan 2016 23:34:58 +0000 (15:34 -0800)
4290. [func] The timers returned by the statistics channel
(indicating current time, server boot time, and
most recent reconfiguration time) are now reported
with millisecond accuracy. [RT #40082]

CHANGES
bin/named/bind9.xsl
bin/named/bind9.xsl.h
bin/named/statschannel.c
doc/arm/notes.xml
lib/isc/unix/include/isc/time.h
lib/isc/unix/time.c
lib/isc/win32/include/isc/time.h
lib/isc/win32/libisc.def.in
lib/isc/win32/time.c

diff --git a/CHANGES b/CHANGES
index 819ccb008b543c457bbefd6071c6840b5ccd2cd7..6911ae672b965da5dc72d87843af01ed25ad4fdb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+4290.  [func]          The timers returned by the statistics channel
+                       (indicating current time, server boot time, and
+                       most recent reconfiguration time) are now reported
+                       with millisecond accuracy. [RT #40082]
+
 4289.  [bug]           The server could crash due to memory being used
                        after it was freed if a zone transfer timed out.
                        [RT #41297]
index 7b8bab109595a5b12612dcf952be9db5ee1bbd77..079f3b48f6176dd9e1db557b2030115ecd75c047 100644 (file)
@@ -17,7 +17,7 @@
 
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
   <xsl:output method="html" indent="yes" version="4.0"/>
-  <xsl:template match="statistics[@version=&quot;3.7&quot;]">
+  <xsl:template match="statistics[@version=&quot;3.8&quot;]">
     <html>
       <head>
         <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
index b42e7f19b4a45796cbf5cdb46360e55a399182ce..d97279642cb7844cf948bc3b304a984e9d2a7860 100644 (file)
@@ -22,7 +22,7 @@ static char xslmsg[] =
        "\n"
        "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns=\"http://www.w3.org/1999/xhtml\" version=\"1.0\">\n"
        " <xsl:output method=\"html\" indent=\"yes\" version=\"4.0\"/>\n"
-       " <xsl:template match=\"statistics[@version=&quot;3.7&quot;]\">\n"
+       " <xsl:template match=\"statistics[@version=&quot;3.8&quot;]\">\n"
        " <html>\n"
        " <head>\n"
        " <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
index a0b727f8f96079a7738ce0ad5b6d0edce05ce493..8353eef47b9f4db5c8e902ec10755c79a75698bf 100644 (file)
@@ -1411,9 +1411,9 @@ static isc_result_t
 generatexml(ns_server_t *server, isc_uint32_t flags,
            int *buflen, xmlChar **buf)
 {
-       char boottime[sizeof "yyyy-mm-ddThh:mm:ssZ"];
-       char configtime[sizeof "yyyy-mm-ddThh:mm:ssZ"];
-       char nowstr[sizeof "yyyy-mm-ddThh:mm:ssZ"];
+       char boottime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
+       char configtime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
+       char nowstr[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
        isc_time_t now;
        xmlTextWriterPtr writer = NULL;
        xmlDocPtr doc = NULL;
@@ -1433,9 +1433,9 @@ generatexml(ns_server_t *server, isc_uint32_t flags,
        isc_result_t result;
 
        isc_time_now(&now);
-       isc_time_formatISO8601(&ns_g_boottime, boottime, sizeof boottime);
-       isc_time_formatISO8601(&ns_g_configtime, configtime, sizeof configtime);
-       isc_time_formatISO8601(&now, nowstr, sizeof nowstr);
+       isc_time_formatISO8601ms(&ns_g_boottime, boottime, sizeof boottime);
+       isc_time_formatISO8601ms(&ns_g_configtime, configtime, sizeof configtime);
+       isc_time_formatISO8601ms(&now, nowstr, sizeof nowstr);
 
        writer = xmlNewTextWriterDoc(&doc, 0);
        if (writer == NULL)
@@ -1445,7 +1445,7 @@ generatexml(ns_server_t *server, isc_uint32_t flags,
                        ISC_XMLCHAR "type=\"text/xsl\" href=\"/bind9.xsl\""));
        TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "statistics"));
        TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "version",
-                                        ISC_XMLCHAR "3.7"));
+                                        ISC_XMLCHAR "3.8"));
 
        /* Set common fields for statistics dump */
        dumparg.type = isc_statsformat_xml;
@@ -2071,9 +2071,9 @@ generatejson(ns_server_t *server, size_t *msglen,
        isc_uint64_t tcpinsizestat_values[dns_sizecounter_in_max];
        isc_uint64_t tcpoutsizestat_values[dns_sizecounter_out_max];
        stats_dumparg_t dumparg;
-       char boottime[sizeof "yyyy-mm-ddThh:mm:ssZ"];
-       char configtime[sizeof "yyyy-mm-ddThh:mm:ssZ"];
-       char nowstr[sizeof "yyyy-mm-ddThh:mm:ssZ"];
+       char boottime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
+       char configtime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
+       char nowstr[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
        isc_time_t now;
 
        REQUIRE(msglen != NULL);
@@ -2092,11 +2092,11 @@ generatejson(ns_server_t *server, size_t *msglen,
        json_object_object_add(bindstats, "json-stats-version", obj);
 
        isc_time_now(&now);
-       isc_time_formatISO8601(&ns_g_boottime,
+       isc_time_formatISO8601ms(&ns_g_boottime,
                               boottime, sizeof(boottime));
-       isc_time_formatISO8601(&ns_g_configtime,
+       isc_time_formatISO8601ms(&ns_g_configtime,
                               configtime, sizeof configtime);
-       isc_time_formatISO8601(&now, nowstr, sizeof(nowstr));
+       isc_time_formatISO8601ms(&now, nowstr, sizeof(nowstr));
 
        obj = json_object_new_string(boottime);
        CHECKMEM(obj);
index f36340ed5bd10f5c2410dee6bd20decfff7725ab..da7e3d4e1aee142944a71e53df16621fe3bef46f 100644 (file)
   <section xml:id="relnotes_changes"><info><title>Feature Changes</title></info>
 
     <itemizedlist>
+      <listitem>
+        <para>
+         The timers returned by the statistics channel (indicating current
+         time, server boot time, and most recent reconfiguration time) are
+         now reported with millisecond accuracy. [RT #40082]
+       </para>
+      </listitem>
       <listitem>
         <para>
          Updated the compiled in addresses for H.ROOT-SERVERS.NET.
index fd767040aeca1c4c996d671d65d6f32cc16d0bdf..ee45ce8f4096ad13a0430cb555b278ee72f8c443 100644 (file)
@@ -346,6 +346,20 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len);
  *
  */
 
+void
+isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len);
+/*%<
+ * Format the time 't' into the buffer 'buf' of length 'len',
+ * using the ISO8601 format: "yyyy-mm-ddThh:mm:ss.sssZ"
+ * If the text does not fit in the buffer, the result is indeterminate,
+ * but is always guaranteed to be null terminated.
+ *
+ *  Requires:
+ *\li      'len' > 0
+ *\li      'buf' points to an array of at least len chars
+ *
+ */
+
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_TIME_H */
index 97ccfa06779a412df8f6fa185f2bb64bc369bf70..522cad0409d7a4a5faa5621df31e66f773ae8a48 100644 (file)
@@ -39,6 +39,7 @@
 
 #define NS_PER_S       1000000000      /*%< Nanoseconds per second. */
 #define NS_PER_US      1000            /*%< Nanoseconds per microsecond. */
+#define NS_PER_MS      1000000         /*%< Nanoseconds per millisecond. */
 #define US_PER_S       1000000         /*%< Microseconds per second. */
 
 /*
@@ -392,7 +393,7 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
        INSIST(flen < len);
        if (flen != 0)
                snprintf(buf + flen, len - flen,
-                        ".%03u", t->nanoseconds / 1000000);
+                        ".%03u", t->nanoseconds / NS_PER_MS);
        else {
                strncpy(buf, "99-Bad-9999 99:99:99.999", len);
                buf[len - 1] = 0;
@@ -443,3 +444,20 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
        flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%SZ", gmtime(&now));
        INSIST(flen < len);
 }
+
+void
+isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) {
+       time_t now;
+       unsigned int flen;
+
+       REQUIRE(len > 0);
+
+       now = (time_t)t->seconds;
+       flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%SZ", gmtime(&now));
+       INSIST(flen < len);
+       if (flen == len - 5) {
+               flen -= 1; /* rewind one character */
+               snprintf(buf + flen, len - flen, ".%03uZ",
+                        t->nanoseconds / NS_PER_MS);
+       }
+}
index 5b97c5358830d5711cce151cddc41deecc7ef5f4..b48ccf8160c4f4010634f6f777d18ef9f0325bbc 100644 (file)
@@ -310,6 +310,20 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len);
  *
  */
 
+void
+isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len);
+/*%<
+ * Format the time 't' into the buffer 'buf' of length 'len',
+ * using the ISO8601 format: "yyyy-mm-ddThh:mm:ss.sssZ"
+ * If the text does not fit in the buffer, the result is indeterminate,
+ * but is always guaranteed to be null terminated.
+ *
+ *  Requires:
+ *\li      'len' > 0
+ *\li      'buf' points to an array of at least len chars
+ *
+ */
+
 isc_uint32_t
 isc_time_seconds(const isc_time_t *t);
 /*%<
index 42e32e1d784d12ea05152492e084c66d0d210479..f4d4025e0fc77312573d81027f51dad588e4c432 100644 (file)
@@ -681,6 +681,7 @@ isc_thread_setconcurrency
 isc_time_add
 isc_time_compare
 isc_time_formatISO8601
+isc_time_formatISO8601ms
 isc_time_formathttptimestamp
 isc_time_formattimestamp
 isc_time_isepoch
index e478edcb82a0c87f7afe26ab8fabed7f570f773f..54c8b472aaffe6638a9e23116ed6e56356fb9d64 100644 (file)
@@ -343,7 +343,7 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
        char DateBuf[50];
        char TimeBuf[50];
 
-/* strtime() format: "%Y-%m-%dT%H:%M:%SZ" */
+       /* strtime() format: "%Y-%m-%dT%H:%M:%SZ" */
 
        REQUIRE(len > 0);
        if (FileTimeToSystemTime(&t->absolute, &st)) {
@@ -357,3 +357,25 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
                buf[0] = 0;
        }
 }
+
+void
+isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) {
+       SYSTEMTIME st;
+       char DateBuf[50];
+       char TimeBuf[50];
+
+       /* strtime() format: "%Y-%m-%dT%H:%M:%S.SSSZ" */
+
+       REQUIRE(len > 0);
+       if (FileTimeToSystemTime(&t->absolute, &st)) {
+               GetDateFormat(LOCALE_NEUTRAL, 0, &st, "yyyy-MM-dd",
+                             DateBuf, 50);
+               GetTimeFormat(LOCALE_NEUTRAL,
+                             TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT,
+                             &st, "hh':'mm':'ss", TimeBuf, 50);
+               snprintf(buf, len, "%sT%s.%03uZ", DateBuf, TimeBuf,
+                        st.wMilliseconds);
+       } else {
+               buf[0] = 0;
+       }
+}