summaryrefslogtreecommitdiff
path: root/src/packetSource.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-03-22 17:50:10 +0000
committerChristian Pointner <equinox@anytun.org>2009-03-22 17:50:10 +0000
commitfd419ce4f2bcadae313f4f368361c733c1249ae9 (patch)
treeba244a9428e8b9cd5e40ceaa3857ab15a7a1a93e /src/packetSource.cpp
parentupdated config (new option auth-tag-length) (diff)
added error callback to resolver for better handling
of resolvCallback exceptions
Diffstat (limited to 'src/packetSource.cpp')
-rw-r--r--src/packetSource.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/packetSource.cpp b/src/packetSource.cpp
index 5542ee9..e291175 100644
--- a/src/packetSource.cpp
+++ b/src/packetSource.cpp
@@ -37,6 +37,7 @@
#include "log.h"
#include "resolver.h"
#include "options.h"
+#include "signalController.h"
void PacketSource::waitUntilReady()
{
@@ -45,12 +46,12 @@ void PacketSource::waitUntilReady()
UDPPacketSource::UDPPacketSource(std::string port) : sock_(io_service_)
{
- gResolver.resolveUdp("", port, boost::bind(&UDPPacketSource::onResolve, this, _1), gOpt.getResolvAddrType());
+ gResolver.resolveUdp("", port, boost::bind(&UDPPacketSource::onResolve, this, _1), boost::bind(&UDPPacketSource::onError, this, _1), gOpt.getResolvAddrType());
}
UDPPacketSource::UDPPacketSource(std::string localaddr, std::string port) : sock_(io_service_)
{
- gResolver.resolveUdp(localaddr, port, boost::bind(&UDPPacketSource::onResolve, this, _1), gOpt.getResolvAddrType());
+ gResolver.resolveUdp(localaddr, port, boost::bind(&UDPPacketSource::onResolve, this, _1), boost::bind(&UDPPacketSource::onError, this, _1), gOpt.getResolvAddrType());
}
void UDPPacketSource::onResolve(const boost::asio::ip::udp::endpoint& e)
@@ -61,6 +62,11 @@ void UDPPacketSource::onResolve(const boost::asio::ip::udp::endpoint& e)
ready_sem_.up();
}
+void UDPPacketSource::onError(const std::runtime_error& e)
+{
+ gSignalController.inject(SIGERROR, e.what());
+}
+
u_int32_t UDPPacketSource::recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint& remote)
{
return static_cast<u_int32_t>(sock_.receive_from(boost::asio::buffer(buf, len), remote));