TestWatchNotify::TestWatchNotify(CephContext *cct)
: m_cct(cct), m_finisher(new Finisher(cct)), m_handle(), m_notify_id(),
- m_file_watcher_lock("librados::TestWatchNotify::m_file_watcher_lock") {
+ m_file_watcher_lock("librados::TestWatchNotify::m_file_watcher_lock"),
+ m_pending_notifies(0) {
m_cct->get();
m_finisher->start();
}
: lock("TestWatchNotify::Watcher::lock") {
}
+void TestWatchNotify::flush() {
+ Mutex::Locker file_watcher_locker(m_file_watcher_lock);
+ while (m_pending_notifies > 0) {
+ m_file_watcher_cond.Wait(m_file_watcher_lock);
+ }
+}
+
int TestWatchNotify::list_watchers(const std::string& o,
std::list<obj_watch_t> *out_watchers) {
SharedWatcher watcher = get_watcher(o);
RWLock::WLocker l(watcher->lock);
{
Mutex::Locker l2(m_file_watcher_lock);
+ ++m_pending_notifies;
uint64_t notify_id = ++m_notify_id;
SharedNotifyHandle notify_handle(new NotifyHandle());
Mutex::Locker l3(*lock);
*done = true;
cond->Signal();
+
+ {
+ Mutex::Locker file_watcher_locker(m_file_watcher_lock);
+ if (--m_pending_notifies == 0) {
+ m_file_watcher_cond.Signal();
+ }
+ }
}
} // namespace librados
TestWatchNotify(CephContext *cct);
~TestWatchNotify();
+ void flush();
int list_watchers(const std::string& o,
std::list<obj_watch_t> *out_watchers);
int notify(const std::string& o, bufferlist& bl,
uint64_t m_notify_id;
Mutex m_file_watcher_lock;
+ Cond m_file_watcher_cond;
+ uint64_t m_pending_notifies;
+
FileWatchers m_file_watchers;
SharedWatcher get_watcher(const std::string& oid);