This is expected to make system debugging easier.

This raises two compatibility issues:
1. When a new ovsdb-tool reads an old database, it will multiply by 1000 any
  timestamp it reads which is less than 1<<31. Since this date corresponds to
  Jan 16 1970 this is unlikely to cause a problem.
2. When an old ovsdb-tool reads a new database, it will interpret the
  millisecond timestamps as seconds and report dates in the far future; the
  time of this commit is reported as the year 45672 (each second since the
  epoch is interpreted as 16 minutes).

Signed-off-by: Paul Ingram <[email protected]>
---
 NEWS               |    6 +++---
 ovsdb/file.c       |    2 +-
 ovsdb/ovsdb-tool.c |   12 +++++++++---
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 4dd9568..c7d3106 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,8 @@
 Post-v2.0.0
 ---------------------
-    - Log files now report times with millisecond resolution.  (Previous
-      versions only reported whole seconds.)
-
+    - Log file timestamps and ovsdb commit timestamps are now reported
+      with millisecond resolution.  (Previous versions only reported
+      whole seconds.)
 
 v2.0.0 - xx xxx xxxx
 ---------------------
diff --git a/ovsdb/file.c b/ovsdb/file.c
index 87cbce6..4835950 100644
--- a/ovsdb/file.c
+++ b/ovsdb/file.c
@@ -773,7 +773,7 @@ ovsdb_file_txn_commit(struct json *json, const char 
*comment,
     if (comment) {
         json_object_put_string(json, "_comment", comment);
     }
-    json_object_put(json, "_date", json_integer_create(time_wall()));
+    json_object_put(json, "_date", json_integer_create(time_wall_msec()));
 
     error = ovsdb_log_write(log, json);
     json_destroy(json);
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index 8670127..077e7f5 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -518,9 +518,15 @@ do_show_log(int argc, char *argv[])
 
             date = shash_find_data(json_object(json), "_date");
             if (date && date->type == JSON_INTEGER) {
-                time_t t = json_integer(date);
-                char *s = xastrftime_msec(" %Y-%m-%d %H:%M:%S",
-                                          t * 1000LL, true);
+                long long int t = json_integer(date);
+                char *s;
+
+                if (t < INT32_MAX) {
+                    /* Older versions of ovsdb wrote timestamps in seconds. */
+                    t *= 1000;
+                }
+
+               s = xastrftime_msec(" %Y-%m-%d %H:%M:%S.###", t, true);
                 fputs(s, stdout);
                 free(s);
             }
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to