X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FFileHandle.cci;h=79308aee6ee4ff85d688a4ef95ad98eb36c87393;hb=3cb0a2ff50b8f1111da34b696e64fb1b037cd683;hp=bcb6d50efb49c41afd4a4d6fb9ed83a7e01fb346;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Socket/FileHandle.cci b/Socket/FileHandle.cci index bcb6d50..79308ae 100644 --- a/Socket/FileHandle.cci +++ b/Socket/FileHandle.cci @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -27,6 +27,7 @@ //#include "FileHandle.ih" // Custom includes +#include "../Utils/senfassert.hh" #include #include "../Utils/Exception.hh" @@ -40,33 +41,6 @@ prefix_ senf::FileBody::FileBody(int fd) : fd_(fd) {} -prefix_ senf::FileBody::~FileBody() -{ - if (valid()) - try { - close(); - } - catch (...) { - terminate(); - } -} - -prefix_ void senf::FileBody::close() -{ - if (!valid()) - throwErrno(EBADF); - v_close(); - fd_ = -1; -} - -prefix_ void senf::FileBody::terminate() -{ - if (valid()) { - v_terminate(); - fd_ = -1; - } -} - prefix_ senf::FileHandle senf::FileBody::handle() { return FileHandle(ptr(this)); @@ -195,6 +169,12 @@ prefix_ senf::FileHandle::FileHandle() : body_(0) {} +prefix_ senf::FileHandle::~FileHandle() +{ + if (body_ && ! body().is_shared()) + body().destroyClose(); +} + prefix_ senf::FileHandle::FileHandle(std::auto_ptr body) : body_(body.release()) {} @@ -205,14 +185,14 @@ prefix_ senf::FileHandle::FileHandle(FileBody::ptr body) prefix_ senf::FileBody & senf::FileHandle::body() { - BOOST_ASSERT(body_); + SENF_ASSERT(body_); return *body_; } prefix_ senf::FileBody const & senf::FileHandle::body() const { - BOOST_ASSERT(body_); + SENF_ASSERT(body_); return *body_; }