}
void Watcher::handle_rewatch(int r) {
- ldout(m_cct, 10) "r=" << r << dendl;
+ ldout(m_cct, 10) << "r=" << r << dendl;
WatchState next_watch_state = WATCH_STATE_REGISTERED;
- if (r < 0) {
- // only EBLACKLISTED or ENOENT can be returned
- assert(r == -EBLACKLISTED || r == -ENOENT);
+ if (r == -EBLACKLISTED) {
+ lderr(m_cct) << "client blacklisted" << dendl;
+ next_watch_state = WATCH_STATE_UNREGISTERED;
+ } else if (r == -ENOENT) {
+ lderr(m_cct) << "failed to unwatch: " << cpp_strerror(r) << dendl;
next_watch_state = WATCH_STATE_UNREGISTERED;
+ } else if (r < 0) {
+ next_watch_state = WATCH_STATE_ERROR;
+ if (m_unregister_watch_ctx != nullptr) {
+ ldout(m_cct, 10) << "image is closing, skip rewatch" << dendl;
+ } else {
+ rewatch();
+ }
}
Context *unregister_watch_ctx = nullptr;
void RewatchRequest::handle_rewatch(int r) {
CephContext *cct = reinterpret_cast<CephContext *>(m_ioctx.cct());
ldout(cct, 10) << "r=" << r << dendl;
-
- if (r == -EBLACKLISTED) {
- lderr(cct) << "client blacklisted" << dendl;
- finish(r);
- return;
- } else if (r == -ENOENT) {
- ldout(cct, 5) << "object deleted" << dendl;
- finish(r);
- return;
- } else if (r < 0) {
+ if (r < 0) {
lderr(cct) << "failed to watch object: " << cpp_strerror(r)
<< dendl;
- rewatch();
+ finish(r);
return;
}
InSequence seq;
expect_aio_unwatch(mock_image_ctx, 0);
expect_aio_watch(mock_image_ctx, -EINVAL);
- expect_aio_watch(mock_image_ctx, 0);
C_SaferCond ctx;
MockRewatchRequest *req = MockRewatchRequest::create(mock_image_ctx.md_ctx,
RWLock::WLocker watch_locker(m_watch_lock);
req->send();
}
- ASSERT_EQ(0, ctx.wait());
+ ASSERT_EQ(-EINVAL, ctx.wait());
}
} // namespace watcher