From: Paul Ingram Date: Sat, 14 Sep 2013 01:52:54 +0000 (-0700) Subject: ovsdb: write commit timestamps to millisecond resolution. X-Git-Tag: v2.0~24 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=340a92017eba6661e17698d0594d76b087d38b06 ovsdb: write commit timestamps to millisecond resolution. 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 Signed-off-by: Ben Pfaff --- diff --git a/NEWS b/NEWS index 9df7f8503..e4f1e8d84 100644 --- a/NEWS +++ b/NEWS @@ -24,8 +24,9 @@ v2.0.0 - xx xxx xxxx * New "ofp-parse" for printing OpenFlow messages read from a file. - Added configurable flow caching support to IPFIX exporter. - Dropped support for Linux pre-2.6.32. - - 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.) v1.11.0 - 28 Aug 2013 diff --git a/ovsdb/file.c b/ovsdb/file.c index 4ccf33e72..7c8ac6f29 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -768,7 +768,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 867012743..077e7f5cb 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); }