Commit bb5d14d7 authored by Evan Hunt's avatar Evan Hunt

[master] millisecond granularity for statschannel timers

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]
parent 742cb923
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]
......
......@@ -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'">
......
......@@ -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"
......
......@@ -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);
......
......@@ -564,6 +564,13 @@
<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.
......
......@@ -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 */
......@@ -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);
}
}
......@@ -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);
/*%<
......
......@@ -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
......
......@@ -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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment