From 5c48bae63455253edb4607c2598e204c13ab5081 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 20 Jan 2009 14:40:00 +0000 Subject: fixed linux and bsd tunDevice (filedescriptor gets now closed in case of an exception during object construction) --- src/bsd/tunDevice.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/bsd') diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp index 421c1d5..3bbba35 100644 --- a/src/bsd/tunDevice.cpp +++ b/src/bsd/tunDevice.cpp @@ -124,13 +124,17 @@ void TunDevice::init_post() struct tuninfo ti; - if (ioctl(fd_, TUNGIFINFO, &ti) < 0) + if (ioctl(fd_, TUNGIFINFO, &ti) < 0) { + ::close(fd_); throw std::runtime_error("can't enable multicast for interface"); + } ti.flags |= IFF_MULTICAST; - if (ioctl(fd_, TUNSIFINFO, &ti) < 0) + if (ioctl(fd_, TUNSIFINFO, &ti) < 0) { + ::close(fd_); throw std::runtime_error("can't enable multicast for interface"); + } } #elif defined(__GNUC__) && defined(__FreeBSD__) -- cgit v1.2.3