Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix parsing of high resolution timestamps

  • Loading branch information...
commit 84422c79694ad5ed2cefaa5f27f3c8d0dde8d495 1 parent 68d68ad
Aman Gupta tmm1 authored

Showing 2 changed files with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. +1 1  lib/collectd.js
  2. +6 1 src/collectd.coffee
2  lib/collectd.js
@@ -107,7 +107,7 @@
107 107 _ref = jspack.Unpack("!LL", buf), upper = _ref[0], lower = _ref[1];
108 108 return {
109 109 type: ptype,
110   - value: (upper << 2) + (lower >> 30)
  110 + value: (upper << 2) + ((lower >> 30) & 0x3)
111 111 };
112 112 };
113 113 decode_network_number = function(ptype, plen, buf) {
7 src/collectd.coffee
@@ -96,9 +96,14 @@ decode_network_values = (ptype, plen, buf) ->
96 96 value: (_decode_network_values ptype, plen, buf)
97 97
98 98 decode_network_time = (ptype, plen, buf) ->
  99 + # cdtime_t is (seconds << 30)
  100 + #
  101 + # Ideally we would read a 64bit int and >>30, but javascript
  102 + # can't do that. So we read the upper 32bits, move it over and add
  103 + # the remaining 2 bits for the 34bit time in seconds.
99 104 [upper, lower] = jspack.Unpack("!LL", buf)
100 105 type: ptype
101   - value: (upper << 2) + (lower >> 30)
  106 + value: (upper << 2) + ((lower >> 30) & 0x3)
102 107
103 108 decode_network_number = (ptype, plen, buf) ->
104 109 type: ptype

0 comments on commit 84422c7

Please sign in to comment.
Something went wrong with that request. Please try again.