Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 May 2016 00:34:54 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r300338 - projects/zfsd/head/lib/libdevdctl
Message-ID:  <201605210034.u4L0Ysg7015092@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Sat May 21 00:34:54 2016
New Revision: 300338
URL: https://svnweb.freebsd.org/changeset/base/300338

Log:
  Fix zfsd where the timezone is not UTC
  
  lib/libdevdctl/event.cc
  	Fix a logic error in Event::TimestampEventString that was
  	timestamping events in the local timezone instead of UTC.  Also,
  	simplify the code a bit.
  
  Sponsored by:	Spectra Logic Corp

Modified:
  projects/zfsd/head/lib/libdevdctl/event.cc

Modified: projects/zfsd/head/lib/libdevdctl/event.cc
==============================================================================
--- projects/zfsd/head/lib/libdevdctl/event.cc	Fri May 20 23:28:43 2016	(r300337)
+++ projects/zfsd/head/lib/libdevdctl/event.cc	Sat May 21 00:34:54 2016	(r300338)
@@ -41,7 +41,6 @@
 #include <sys/filio.h>
 #include <sys/param.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 
 #include <err.h>
 #include <fcntl.h>
@@ -50,6 +49,7 @@
 #include <syslog.h>
 #include <unistd.h>
 
+#include <cinttypes>
 #include <cstdarg>
 #include <cstring>
 #include <iostream>
@@ -430,14 +430,13 @@ Event::TimestampEventString(std::string 
 		if (eventString.find("timestamp=") == string::npos) {
 			const size_t bufsize = 32;	// Long enough for a 64-bit int
 			timeval now;
-			struct tm* time_s;
 			char timebuf[bufsize];
 
 			size_t eventEnd(eventString.find_last_not_of('\n') + 1);
 			if (gettimeofday(&now, NULL) != 0)
 				err(1, "gettimeofday");
-			time_s = gmtime(&now.tv_sec);
-			strftime(timebuf, bufsize, " timestamp=%s", time_s);
+			snprintf(timebuf, bufsize, " timestamp=%"PRId64,
+				(int64_t) now.tv_sec);
 			eventString.insert(eventEnd, timebuf);
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605210034.u4L0Ysg7015092>