int ret = waitForRWData(s.getHandle(), false, 1 , 0);
if(ret <= 0 ) {
- vinfolog("Unable to write data to carbon server on %s: %s", server.toStringWithPort(), (ret<0 ? strerror(errno) : "Timeout"));
+ vinfolog("Unable to write data to carbon server on %s: %s", server.toStringWithPort(), (ret<0 ? stringerror() : "Timeout"));
continue;
}
s.setBlocking();
}
else {
if (pipe(pipefds) < 0) {
- errlog("Error creating the TCP thread communication pipe: %s", strerror(errno));
+ errlog("Error creating the TCP thread communication pipe: %s", stringerror());
return;
}
{
int ret = socket(family, type, flags);
if(ret < 0)
- RuntimeError(boost::format("creating socket of type %d: %s") % family % strerror(errno));
+ RuntimeError(boost::format("creating socket of type %d: %s") % family % stringerror());
return ret;
}
int ret = accept(sockfd, (struct sockaddr*)&remote, &remlen);
if(ret < 0)
- RuntimeError(boost::format("accepting new connection on socket: %s") % strerror(errno));
+ RuntimeError(boost::format("accepting new connection on socket: %s") % stringerror());
return ret;
}
{
int ret = listen(sockfd, limit);
if(ret < 0)
- RuntimeError(boost::format("setting socket to listen: %s") % strerror(errno));
+ RuntimeError(boost::format("setting socket to listen: %s") % stringerror());
return ret;
}
{
int ret = setsockopt(sockfd, level, opname, &value, sizeof(value));
if(ret < 0)
- RuntimeError(boost::format("setsockopt for level %d and opname %d to %d failed: %s") % level % opname % value % strerror(errno));
+ RuntimeError(boost::format("setsockopt for level %d and opname %d to %d failed: %s") % level % opname % value % stringerror());
return ret;
}
g_log<<Logger::Info<<e.what()<<", attempting to create"<<endl;
// Attempt to create it, if _that_ fails, there is no hope
if (mkdir(dir.c_str(), 0777) == -1 && errno != EEXIST) {
- g_log<<Logger::Error<<"Could not create '"<<dir<<"': "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Could not create '"<<dir<<"': "<<stringerror()<<endl;
_exit(EXIT_FAILURE);
}
}
uint32_t ret=0;
DIR* dirhdl=opendir(dir.c_str());
if(!dirhdl)
- throw runtime_error("Could not open IXFR directory '" + dir + "': " + strerror(errno));
+ throw runtime_error("Could not open IXFR directory '" + dir + "': " + stringerror());
struct dirent *entry;
while((entry = readdir(dirhdl))) {
string fname=directory +"/"+std::to_string(serial);
FILE* fp=fopen((fname+".partial").c_str(), "w");
if(!fp)
- throw runtime_error("Unable to open file '"+fname+".partial' for writing: "+string(strerror(errno)));
+ throw runtime_error("Unable to open file '"+fname+".partial' for writing: "+string(stringerror()));
records_t soarecord;
soarecord.insert(soa);
fclose(fp);
if (rename( (fname+".partial").c_str(), fname.c_str()) != 0) {
- throw std::runtime_error("Unable to move the zone file for " + zone.toLogString() + " from " + fname + ".partial to " + fname + ": " + string(strerror(errno)));
+ throw std::runtime_error("Unable to move the zone file for " + zone.toLogString() + " from " + fname + ".partial to " + fname + ": " + string(stringerror()));
}
}
void BaseLua4::loadFile(const std::string &fname) {
std::ifstream ifs(fname);
if(!ifs) {
- g_log<<Logger::Error<<"Unable to read configuration file from '"<<fname<<"': "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Unable to read configuration file from '"<<fname<<"': "<<stringerror()<<endl;
return;
}
loadStream(ifs);
{
int tmp = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&tmp, static_cast<unsigned>(sizeof tmp))<0)
- throw PDNSException(string("Setsockopt failed: ")+strerror(errno));
+ throw PDNSException(string("Setsockopt failed: ")+stringerror());
return true;
}
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVERR, &tmp, sizeof(tmp));
}
if (ret < 0) {
- throw PDNSException(string("Setsockopt failed: ") + strerror(errno));
+ throw PDNSException(string("Setsockopt failed: ") + stringerror());
}
#endif
return true;
s=socket(AF_INET,SOCK_DGRAM,0);
if(s<0) {
- g_log<<Logger::Error<<"Unable to acquire UDP socket: "+string(strerror(errno)) << endl;
- throw PDNSException("Unable to acquire a UDP socket: "+string(strerror(errno)));
+ g_log<<Logger::Error<<"Unable to acquire UDP socket: "+string(stringerror()) << endl;
+ throw PDNSException("Unable to acquire a UDP socket: "+string(stringerror()));
}
setCloseOnExec(s);
g_localaddresses.push_back(locala);
if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) {
- string binderror = strerror(errno);
+ string binderror = stringerror();
close(s);
if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-address-nonexist-fail") ) {
g_log<<Logger::Error<<"IPv4 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
g_log<<Logger::Error<<"IPv6 Address Family is not supported - skipping UDPv6 bind" << endl;
return;
} else {
- g_log<<Logger::Error<<"Unable to acquire a UDPv6 socket: "+string(strerror(errno)) << endl;
- throw PDNSException("Unable to acquire a UDPv6 socket: "+string(strerror(errno)));
+ g_log<<Logger::Error<<"Unable to acquire a UDPv6 socket: "+string(stringerror()) << endl;
+ throw PDNSException("Unable to acquire a UDPv6 socket: "+string(stringerror()));
}
}
g_log<<Logger::Error<<"IPv6 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
continue;
} else {
- g_log<<Logger::Error<<"Unable to bind to UDPv6 socket "<< localname <<": "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Unable to bind to UDPv6 socket "<< localname <<": "<<stringerror()<<endl;
throw PDNSException("Unable to bind to UDPv6 socket");
}
}
g_log<<Logger::Error<<"Weird, trying to send a message that needs truncation, "<< buffer.length()<<" > "<<p->getMaxReplyLen()<<". Question was for "<<p->qdomain<<"|"<<p->qtype.getName()<<endl;
}
if(sendmsg(p->getSocket(), &msgh, 0) < 0)
- g_log<<Logger::Error<<"Error sending reply with sendmsg (socket="<<p->getSocket()<<", dest="<<p->d_remote.toStringWithPort()<<"): "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Error sending reply with sendmsg (socket="<<p->getSocket()<<", dest="<<p->d_remote.toStringWithPort()<<"): "<<stringerror()<<endl;
}
DNSPacket *UDPNameserver::receive(DNSPacket *prefilled, std::string& buffer)
sock=pfd.fd;
if((len=recvmsg(sock, &msgh, 0)) < 0 ) {
if(errno != EAGAIN)
- g_log<<Logger::Error<<"recvfrom gave error, ignoring: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"recvfrom gave error, ignoring: "<<stringerror()<<endl;
return 0;
}
break;
else {
string empty;
MT->sendEvent(pident, &empty);
- // cerr<<"Had some kind of error: "<<ret<<", "<<strerror(errno)<<endl;
+ // cerr<<"Had some kind of error: "<<ret<<", "<<stringerror()<<endl;
}
}
string GenUDPQueryResponse(const ComboAddress& dest, const string& query)
// Keep this line below all ::arg().set() statements
if (! ::arg().laxFile(configname.c_str()))
- cerr<<"Warning: unable to read configuration file '"<<configname<<"': "<<strerror(errno)<<endl;
+ cerr<<"Warning: unable to read configuration file '"<<configname<<"': "<<stringerror()<<endl;
#ifdef HAVE_LIBSODIUM
if (sodium_init() == -1) {
int ret=asendtcp(msg, &s); // this will actually do the right thing waiting on the connect
if(ret < 0)
- g_log<<Logger::Warning<<"Error writing carbon data to "<<remote.toStringWithPort()<<": "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Error writing carbon data to "<<remote.toStringWithPort()<<": "<<stringerror()<<endl;
if(ret==0)
g_log<<Logger::Warning<<"Timeout connecting/writing carbon data to "<<remote.toStringWithPort()<<endl;
}
return;
ifstream ifs(fname);
if(!ifs)
- throw PDNSException("Cannot open file '"+fname+"': "+strerror(errno));
+ throw PDNSException("Cannot open file '"+fname+"': "+stringerror());
auto luaconfsLocal = g_luaconfs.getLocal();
lci.generation = luaconfsLocal->generation + 1;
if(of)
of<<getpid()<<endl;
else
- g_log<<Logger::Error<<"Writing pid for "<<getpid()<<" to "<<fname<<" failed: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Writing pid for "<<getpid()<<" to "<<fname<<" failed: "<<stringerror()<<endl;
}
int g_fd1[2], g_fd2[2];
setStatus("Launching child");
if(pipe(g_fd1)<0 || pipe(g_fd2)<0) {
- g_log<<Logger::Critical<<"Unable to open pipe for coprocess: "<<strerror(errno)<<endl;
+ g_log<<Logger::Critical<<"Unable to open pipe for coprocess: "<<stringerror()<<endl;
exit(1);
}
close(g_fd2[1]);
}
if(execvp(argv[0], newargv)<0) {
- g_log<<Logger::Error<<"Unable to execvp '"<<argv[0]<<"': "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Unable to execvp '"<<argv[0]<<"': "<<stringerror()<<endl;
char **p=newargv;
while(*p)
g_log<<Logger::Error<<*p++<<endl;
int ret=waitpid(pid,&status,WNOHANG);
if(ret<0) {
- g_log<<Logger::Error<<"In guardian loop, waitpid returned error: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"In guardian loop, waitpid returned error: "<<stringerror()<<endl;
g_log<<Logger::Error<<"Dying"<<endl;
exit(1);
}
g_log<<Logger::Error<<"No clue what happened! Respawning"<<endl;
}
else {
- g_log<<Logger::Error<<"Unable to fork: "<<strerror(errno)<<endl;
+ g_log<<Logger::Error<<"Unable to fork: "<<stringerror()<<endl;
exit(1);
}
}
if(gethostname(tmp, sizeof(tmp)-1) == 0) {
::arg().set("server-id")=tmp;
} else {
- g_log<<Logger::Warning<<"Unable to get the hostname, NSID and id.server values will be empty: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Unable to get the hostname, NSID and id.server values will be empty: "<<stringerror()<<endl;
}
}
int res = writev(d_fd, iov, pos);
if(res < 0) {
- throw std::runtime_error("Couldn't flush a thing: "+string(strerror(errno)));
+ throw std::runtime_error("Couldn't flush a thing: "+string(stringerror()));
}
if(!res) {
throw std::runtime_error("EOF");
throw ResolverException("Timeout connecting to server");
}
else if(err < 0) {
- throw ResolverException("Error connecting: "+string(strerror(errno)));
+ throw ResolverException("Error connecting: "+string(stringerror()));
}
else {
Utility::socklen_t len=sizeof(err);
}
if (fflush(fp.get()) != 0) {
- g_log<<Logger::Warning<<"Error while flushing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Error while flushing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
return false;
}
if (fsync(fileno(fp.get())) != 0) {
- g_log<<Logger::Warning<<"Error while syncing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Error while syncing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
return false;
}
if (fclose(fp.release()) != 0) {
- g_log<<Logger::Warning<<"Error while writing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Error while writing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
return false;
}
if (rename(temp.c_str(), dumpZoneFileName.c_str()) != 0) {
- g_log<<Logger::Warning<<"Error while moving the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+ g_log<<Logger::Warning<<"Error while moving the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
return false;
}
sock.sendTo(question, dest);
int result=waitForData(sock.getHandle(), 10);
if(result < 0)
- throw std::runtime_error("Error waiting for data: "+string(strerror(errno)));
+ throw std::runtime_error("Error waiting for data: "+string(stringerror()));
if(!result)
throw std::runtime_error("Timeout waiting for data");
sock.recvFrom(reply, dest);