Skip to content

Commit 461ae24

Browse files
committed
don't get confused by bogus timestamps from broken stations
1 parent 93ca884 commit 461ae24

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

navnexus.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void unixDie(const std::string& str)
3535
throw std::runtime_error(str+string(": ")+string(strerror(errno)));
3636
}
3737

38+
// station numbers
3839
vector<uint64_t> getSources()
3940
{
4041
DIR *dir = opendir(g_storage.c_str());
@@ -98,6 +99,10 @@ try
9899
while(getRawNMM(fd, ts, msg, offset)) {
99100
// don't drop data that is only 5 seconds too old
100101
if(make_pair(ts.tv_sec + 5, ts.tv_nsec) >= make_pair(start.tv_sec, start.tv_nsec)) {
102+
if(ts.tv_sec > time(0)) {
103+
cout << "station "<<src <<" is living in the future, skipping message\n";
104+
}
105+
else
101106
rnmms.push_back({ts, msg});
102107
}
103108
++looked;
@@ -126,8 +131,9 @@ try
126131
if(3600 + start.tv_sec - (start.tv_sec % 3600) < time(0))
127132
start.tv_sec = 3600 + start.tv_sec - (start.tv_sec % 3600);
128133
else {
129-
if(!rnmms.empty())
134+
if(!rnmms.empty()) // start off where we left it
130135
start = {rnmms.rbegin()->first.tv_sec, rnmms.rbegin()->first.tv_nsec};
136+
// This is a bit iffy as it relies on the station furthest ahead in time
131137
sleep(1);
132138
}
133139
}

0 commit comments

Comments
 (0)