From: Michal 'vorner' Vaner Date: Tue, 2 Oct 2012 19:21:48 +0000 (+0200) Subject: Merge #2202 X-Git-Tag: trac2402_base~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7eaa1760f3ed6cd57cf1b8458516fa3d457371d7;p=thirdparty%2Fkea.git Merge #2202 The locking of client lists in auth server. This is to allow background loading later on. Conflicts: src/bin/auth/auth_srv.cc src/bin/auth/auth_srv.h --- 7eaa1760f3ed6cd57cf1b8458516fa3d457371d7 diff --cc src/bin/auth/auth_srv.cc index 82a98a4d94,04dc299074..b870ae2cb9 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@@ -942,7 -951,7 +965,12 @@@ AuthSrv::getClientListClasses() const return (result); } + util::thread::Mutex& + AuthSrv::getClientListMutex() const { + return (impl_->mutex_); + } ++ +void +AuthSrv::setTCPRecvTimeout(size_t timeout) { + dnss_->setTCPRecvTimeout(timeout); +} diff --cc src/bin/auth/auth_srv.h index e2ffd71526,ea658bca03..ee7bd52bb2 --- a/src/bin/auth/auth_srv.h +++ b/src/bin/auth/auth_srv.h @@@ -319,16 -322,38 +322,48 @@@ public /// has been set by setClientList. std::vector getClientListClasses() const; + /// \brief Return a mutex for the client lists. + /// + /// Background loading of data uses threads. Therefore we need to protect + /// the client lists by a mutex, so they don't change (or get destroyed) + /// during query processing. Get (and lock) this mutex whenever you do + /// something with the lists and keep it locked until you finish. This + /// is correct: + /// \code + /// { + /// Mutex::Locker locker(auth->getClientListMutex()); + /// boost::shared_ptr + /// list(auth->getClientList(RRClass::IN())); + /// // Do some processing here + /// } + /// \endcode + /// + /// But this is not (it releases the mutex too soon): + /// \code + /// boost::shared_ptr list; + /// { + /// Mutex::Locker locker(auth->getClientListMutex()); + /// list = auth->getClientList(RRClass::IN())); + /// } + /// // Do some processing here + /// \endcode + /// + /// \note This method is const even if you are allowed to modify + /// (lock) the mutex. It's because locking of the mutex is not really + /// a modification of the server object and it is needed to protect the + /// lists even on read-only operations. + isc::util::thread::Mutex& getClientListMutex() const; + + /// \brief Sets the timeout for incoming TCP connections + /// + /// Incoming TCP connections that have not sent their data + /// withing this time are dropped. + /// + /// \param timeout The timeout (in milliseconds). If se to + /// zero, no timeouts are used, and the connection will remain + /// open forever. + void setTCPRecvTimeout(size_t timeout); + private: AuthSrvImpl* impl_; isc::asiolink::SimpleCallback* checkin_;