msgh.msg_control=NULL;
if(i->second.anyLocal) {
- addCMsgSrcAddr(&msgh, cbuf, i->second.anyLocal.get_ptr(), 0);
+ addCMsgSrcAddr(&msgh, &cbuf, i->second.anyLocal.get_ptr(), 0);
}
- if(sendmsg(i->second.outsock, &msgh, 0) < 0)
- g_log<<Logger::Warning<<"dnsproxy.cc: Error sending reply with sendmsg (socket="<<i->second.outsock<<"): "<<strerror(errno)<<endl;
-
+ if(sendmsg(i->second.outsock, &msgh, 0) < 0) {
+ int err = errno;
+ g_log<<Logger::Warning<<"dnsproxy.cc: Error sending reply with sendmsg (socket="<<i->second.outsock<<"): "<<stringerror(err)<<endl;
+ }
i->second.created=0;
}
}
msgh.msg_control=NULL;
if(g_fromtosockets.count(dc->d_socket)) {
- addCMsgSrcAddr(&msgh, cbuf, &dc->d_local, 0);
+ addCMsgSrcAddr(&msgh, &cbuf, &dc->d_local, 0);
}
- if(sendmsg(dc->d_socket, &msgh, 0) < 0 && g_logCommonErrors)
- g_log<<Logger::Warning<<"Sending UDP reply to client "<<dc->getRemote()<<" failed with: "<<strerror(errno)<<endl;
+ if(sendmsg(dc->d_socket, &msgh, 0) < 0 && g_logCommonErrors) {
+ int err = errno;
+ g_log << Logger::Warning << "Sending UDP reply to client " << dc->getRemote() << " failed with: "
+ << strerror(err) << endl;
+ }
if(variableAnswer || sr.wasVariable()) {
g_stats.variableResponses++;
msgh.msg_control=NULL;
if(g_fromtosockets.count(fd)) {
- addCMsgSrcAddr(&msgh, cbuf, &destaddr, 0);
+ addCMsgSrcAddr(&msgh, &cbuf, &destaddr, 0);
}
- if(sendmsg(fd, &msgh, 0) < 0 && g_logCommonErrors)
- g_log<<Logger::Warning<<"Sending UDP reply to client "<<source.toStringWithPort()<<(source != fromaddr ? " (via "+fromaddr.toStringWithPort()+")" : "")<<" failed with: "<<strerror(errno)<<endl;
-
+ if(sendmsg(fd, &msgh, 0) < 0 && g_logCommonErrors) {
+ int err = errno;
+ g_log << Logger::Warning << "Sending UDP reply to client " << source.toStringWithPort()
+ << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << " failed with: "
+ << strerror(err) << endl;
+ }
if(response.length() >= sizeof(struct dnsheader)) {
struct dnsheader tmpdh;
memcpy(&tmpdh, response.c_str(), sizeof(tmpdh));