fix up compilation on raspberry, caught by CTF
parent
95f4502928
commit
e1e3721561
12
navcat.cc
12
navcat.cc
|
@ -98,7 +98,9 @@ static size_t writen2(int fd, const void *buf, size_t count)
|
|||
|
||||
void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
|
||||
{
|
||||
pair<int64_t, int64_t> start(startTime, 0);
|
||||
timespec start;
|
||||
start.tv_sec = startTime;
|
||||
start.tv_nsec = 0;
|
||||
|
||||
// so we have a ton of files, and internally these are not ordered
|
||||
map<string,uint32_t> fpos;
|
||||
|
@ -107,7 +109,7 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
|
|||
auto srcs = getSources(dir);
|
||||
rnmms.clear();
|
||||
for(const auto& src: srcs) {
|
||||
string fname = getPath(dir, start.first, src);
|
||||
string fname = getPath(dir, start.tv_sec, src);
|
||||
FILE* fp = fopen(fname.c_str(), "r");
|
||||
if(!fp)
|
||||
continue;
|
||||
|
@ -124,7 +126,7 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
|
|||
struct timespec ts;
|
||||
while(getRawNMM(fp, ts, msg, offset)) {
|
||||
// don't drop data that is only 5 seconds too old
|
||||
if(make_pair(ts.tv_sec + 5, ts.tv_nsec) >= start) {
|
||||
if(make_pair(ts.tv_sec + 5, ts.tv_nsec) >= make_pair(start.tv_sec, start.tv_nsec)) {
|
||||
rnmms.push_back({ts, msg});
|
||||
}
|
||||
++looked;
|
||||
|
@ -150,8 +152,8 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
|
|||
//fwrite(buf.c_str(), 1, buf.size(), stdout);
|
||||
writen2(1, buf.c_str(), buf.size());
|
||||
}
|
||||
if(3600 + start.first - (start.first%3600) < stopTime)
|
||||
start.first = 3600 + start.first - (start.first%3600);
|
||||
if(3600 + start.tv_sec - (start.tv_sec%3600) < stopTime)
|
||||
start.tv_sec = 3600 + start.tv_sec - (start.tv_sec%3600);
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
|
12
navnexus.cc
12
navnexus.cc
|
@ -60,7 +60,9 @@ try
|
|||
{
|
||||
cerr<<"New downstream client "<<client.toStringWithPort() << endl;
|
||||
|
||||
pair<int64_t, int64_t> start(startTime, 0);
|
||||
timespec start;
|
||||
start.tv_sec = startTime;
|
||||
start.tv_nsec = 0;
|
||||
|
||||
// so we have a ton of files, and internally these are not ordered
|
||||
map<string,uint32_t> fpos;
|
||||
|
@ -69,7 +71,7 @@ try
|
|||
auto srcs = getSources();
|
||||
rnmms.clear();
|
||||
for(const auto& src: srcs) {
|
||||
string fname = getPath(g_storage, start.first, src);
|
||||
string fname = getPath(g_storage, start.tv_sec, src);
|
||||
int fd = open(fname.c_str(), O_RDONLY);
|
||||
if(fd < 0)
|
||||
continue;
|
||||
|
@ -88,7 +90,7 @@ try
|
|||
|
||||
while(getRawNMM(fd, ts, msg, offset)) {
|
||||
// don't drop data that is only 5 seconds too old
|
||||
if(make_pair(ts.tv_sec + 5, ts.tv_nsec) >= start) {
|
||||
if(make_pair(ts.tv_sec + 5, ts.tv_nsec) >= make_pair(start.tv_sec, start.tv_nsec)) {
|
||||
rnmms.push_back({ts, msg});
|
||||
}
|
||||
++looked;
|
||||
|
@ -114,8 +116,8 @@ try
|
|||
SWriten(clientfd, buf);
|
||||
}
|
||||
cout<<"Done"<<endl;
|
||||
if(3600 + start.first - (start.first%3600) < time(0))
|
||||
start.first = 3600 + start.first - (start.first%3600);
|
||||
if(3600 + start.tv_sec - (start.tv_sec % 3600) < time(0))
|
||||
start.tv_sec = 3600 + start.tv_sec - (start.tv_sec % 3600);
|
||||
else {
|
||||
if(!rnmms.empty())
|
||||
start = {rnmms.rbegin()->first.tv_sec, rnmms.rbegin()->first.tv_nsec};
|
||||
|
|
Loading…
Reference in New Issue