From: g0dil Date: Tue, 2 Jun 2009 08:33:23 +0000 (+0000) Subject: Socket: Fix NetdeviceController X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a15c5e75964d82cb1b2f64275ae810ed5cc85814;p=senf.git Socket: Fix NetdeviceController git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1218 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/NetdeviceController.cc b/Socket/NetdeviceController.cc index c5c2ca4..a8f6a19 100644 --- a/Socket/NetdeviceController.cc +++ b/Socket/NetdeviceController.cc @@ -169,11 +169,6 @@ prefix_ int senf::NetdeviceController::interfaceIndex() return ifindex_; } -prefix_ senf::NetdeviceController::~NetdeviceController() -{ - close( sockfd_->fd); -} - prefix_ void senf::NetdeviceController::ifrName(ifreq& ifr) const { @@ -199,24 +194,22 @@ prefix_ senf::NetdeviceController::SockFd::SockFd() { if ( fd < 0) SENF_THROW_SYSTEM_EXCEPTION("Could not open socket for NetdeviceController."); + std::cerr << ">>Made SockFd: " << fd << std::endl; } prefix_ senf::NetdeviceController::SockFd::~SockFd() { + std::cerr << ">>Dispose SockFd: " << fd << std::endl; ::close(fd); } prefix_ senf::NetdeviceController::SockFd::ptr senf::NetdeviceController::sockfd() { static boost::weak_ptr sockfd; - - if (sockfd.expired()) { - SockFd::ptr newsockfd (new SockFd()); - sockfd = newsockfd; - return newsockfd; - } - return sockfd.lock(); - + SockFd::ptr p (sockfd.lock()); + if (!p) + sockfd = p = SockFd::ptr(new SockFd()); + return p; } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Socket/NetdeviceController.hh b/Socket/NetdeviceController.hh index 521e129..e969cda 100644 --- a/Socket/NetdeviceController.hh +++ b/Socket/NetdeviceController.hh @@ -55,8 +55,6 @@ namespace senf { ///< Construct a new controller for the given interface name. explicit NetdeviceController(int interface_index); ///< Construct a new controller for the given interface index. - virtual ~NetdeviceController(); - int interfaceIndex() const; ///< return the interface index MACAddress hardwareAddress() const; ///< return hardware address