BIND 10 trac2861, updated. 32044b839f83bba409fad29df68e94247e7a94a0 [2861] Create a socket pair
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jul 4 09:18:18 UTC 2013
The branch, trac2861 has been updated
via 32044b839f83bba409fad29df68e94247e7a94a0 (commit)
from 6ad2bdd472dd5ef1156577667c09bc0bd90d3f39 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 32044b839f83bba409fad29df68e94247e7a94a0
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date: Thu Jul 4 11:18:03 2013 +0200
[2861] Create a socket pair
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/datasrc_clients_mgr.h | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/datasrc_clients_mgr.h b/src/bin/auth/datasrc_clients_mgr.h
index 3b79bed..29991dd 100644
--- a/src/bin/auth/datasrc_clients_mgr.h
+++ b/src/bin/auth/datasrc_clients_mgr.h
@@ -132,6 +132,24 @@ private:
boost::shared_ptr<datasrc::ConfigurableClientList> >
ClientListsMap;
+ class FDGuard : boost::noncopyable {
+ public:
+ FDGuard(DataSrcClientsMgrBase *mgr) :
+ mgr_(mgr)
+ {}
+ ~FDGuard() {
+ if (mgr_->read_fd_ != -1) {
+ close(mgr_->read_fd_);
+ }
+ if (mgr_->write_fd_ != -1) {
+ close(mgr_->write_fd_);
+ }
+ }
+ private:
+ DataSrcClientsMgrBase* mgr_;
+ };
+ friend class FDGuard;
+
public:
/// \brief Thread-safe accessor to the data source client lists.
///
@@ -197,8 +215,10 @@ public:
/// \throw isc::Unexpected general unexpected system errors.
DataSrcClientsMgrBase(asiolink::IOService&) :
clients_map_(new ClientListsMap),
+ fd_guard_(new FDGuard(this)),
+ read_fd_(-1), write_fd_(-1),
builder_(&command_queue_, &callback_queue_, &cond_, &queue_mutex_,
- &clients_map_, &map_mutex_, -1 /* TEMPORARY */),
+ &clients_map_, &map_mutex_, createFds()),
builder_thread_(boost::bind(&BuilderType::run, &builder_))
{}
@@ -360,6 +380,18 @@ private:
cond_.signal();
}
+ int createFds() {
+ int fds[2];
+ int result = socketpair(AF_LOCAL, SOCK_STREAM, 0, fds);
+ if (result != 0) {
+ isc_throw(Unexpected, "Can't create socket pair: " <<
+ strerror(errno));
+ }
+ read_fd_ = fds[0];
+ write_fd_ = fds[1];
+ return write_fd_;
+ }
+
//
// The following are shared with the builder.
//
@@ -374,6 +406,8 @@ private:
MutexType queue_mutex_; // mutex to protect the queue
datasrc::ClientListMapPtr clients_map_;
// map of actual data source client objects
+ boost::scoped_ptr<FDGuard> fd_guard_; // A guard to close the fds.
+ int read_fd_, write_fd_; // Descriptors for wakeup
MutexType map_mutex_; // mutex to protect the clients map
BuilderType builder_;
More information about the bind10-changes
mailing list