{
ceph_spin_init(&_service_thread_lock);
ceph_spin_init(&_associated_objs_lock);
+ ceph_spin_init(&_fork_watchers_lock);
ceph_spin_init(&_feature_lock);
ceph_spin_init(&_cct_perf_lock);
delete _conf;
ceph_spin_destroy(&_service_thread_lock);
+ ceph_spin_destroy(&_fork_watchers_lock);
ceph_spin_destroy(&_associated_objs_lock);
ceph_spin_destroy(&_feature_lock);
ceph_spin_destroy(&_cct_perf_lock);
return _set_gid_string;
}
+ class ForkWatcher {
+ public:
+ virtual ~ForkWatcher() {}
+ virtual void handle_pre_fork() = 0;
+ virtual void handle_post_fork() = 0;
+ };
+
+ void register_fork_watcher(ForkWatcher *w) {
+ ceph_spin_lock(&_fork_watchers_lock);
+ _fork_watchers.push_back(w);
+ ceph_spin_unlock(&_fork_watchers_lock);
+ }
+
+ void notify_pre_fork() {
+ ceph_spin_lock(&_fork_watchers_lock);
+ for (auto &&t : _fork_watchers)
+ t->handle_pre_fork();
+ ceph_spin_unlock(&_fork_watchers_lock);
+ }
+
+ void notify_post_fork() {
+ ceph_spin_lock(&_fork_watchers_lock);
+ for (auto &&t : _fork_watchers)
+ t->handle_post_fork();
+ ceph_spin_unlock(&_fork_watchers_lock);
+ }
+
private:
struct SingletonWrapper : boost::noncopyable {
virtual ~SingletonWrapper() {}
ceph_spinlock_t _associated_objs_lock;
std::map<std::string, SingletonWrapper*> _associated_objs;
+ ceph_spinlock_t _fork_watchers_lock;
+ std::vector<ForkWatcher*> _fork_watchers;
+
// crypto
CryptoHandler *_crypto_none;
CryptoHandler *_crypto_aes;
return -1;
}
+ cct->notify_pre_fork();
// stop log thread
cct->_log->flush();
cct->_log->stop();
{
// restart log thread
cct->_log->start();
+ cct->notify_post_fork();
/* This is the old trick where we make file descriptors 0, 1, and possibly 2
* point to /dev/null.