]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Merge #2202
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 2 Oct 2012 19:21:48 +0000 (21:21 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 2 Oct 2012 19:21:56 +0000 (21:21 +0200)
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

1  2 
configure.ac
src/bin/auth/Makefile.am
src/bin/auth/auth_srv.cc
src/bin/auth/auth_srv.h
src/bin/auth/benchmarks/Makefile.am
src/bin/auth/command.cc
src/bin/auth/tests/Makefile.am
src/bin/auth/tests/auth_srv_unittest.cc

diff --cc configure.ac
Simple merge
Simple merge
index 82a98a4d9496d303a2cdf4ab4c4b419a680a1560,04dc299074a84c112e0d0884f1225e31097112f0..b870ae2cb929434309a6335ee4b9a496c9d5eefc
@@@ -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);
 +}
index e2ffd71526c73ac104214728870d2d35d6770239,ea658bca032eae790c6679dec9257ab25e14fd5b..ee7bd52bb2add04caef812d5df3b7995044bc55a
@@@ -319,16 -322,38 +322,48 @@@ public
      ///     has been set by setClientList.
      std::vector<isc::dns::RRClass> 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<isc::datasrc::ConfigurableClientList>
+     ///    list(auth->getClientList(RRClass::IN()));
+     ///  // Do some processing here
+     /// }
+     /// \endcode
+     ///
+     /// But this is not (it releases the mutex too soon):
+     /// \code
+     /// boost::shared_ptr<isc::datasrc::ConfigurableClientList> 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_;
Simple merge
Simple merge
Simple merge