{
cout<<"Connecting to "<<server.toStringWithPort()<<endl;
int fd=socket(server.sin4.sin_family, SOCK_STREAM, 0);
+ if (fd < 0) {
+ cerr<<"Unable to connect to "<<server.toStringWithPort()<<endl;
+ return;
+ }
SConnect(fd, server);
SodiumNonce theirs, ours;
msg.assign(resp.get(), len);
msg=sodDecryptSym(msg, g_key, theirs);
cout<<msg<<endl;
+ close(fd);
return;
}
else
ret.insert({count++, {rc.second.toString(), rc.first, 100.0*rc.first/total}});
}
- ret.insert({count, {"Rest", rest, 100.0*rest/total}});
+ ret.insert({count, {"Rest", rest, total > 0 ? 100.0*rest/total : 100.0}});
return ret;
}
else
g_outputBuffer += (fmt % (count++) % rc.second.toString() % rc.first % (100.0*rc.first/total)).str();
}
- g_outputBuffer += (fmt % (count) % "Rest" % rest % (100.0*rest/total)).str();
+ g_outputBuffer += (fmt % (count) % "Rest" % rest % (total > 0 ? 100.0*rest/total : 100.0)).str();
});
g_lua.writeFunction("getTopQueries", [](unsigned int top, boost::optional<int> labels) {
else
ret.insert({count++, {rc.second.toString(), rc.first, 100.0*rc.first/total}});
}
- ret.insert({count, {"Rest", rest, 100.0*rest/total}});
+ ret.insert({count, {"Rest", rest, total > 0 ? 100.0*rest/total : 100.0}});
return ret;
});
{
DownstreamState(const ComboAddress& remote_, const ComboAddress& sourceAddr_, unsigned int sourceItf);
DownstreamState(const ComboAddress& remote_): DownstreamState(remote_, ComboAddress(), 0) {}
+ ~DownstreamState()
+ {
+ if (fd >= 0)
+ close(fd);
+ }
int fd;
std::thread tid;