Skip to content

Commit d0499ae

Browse files
committed
rgw: rgw_rados_ref::watch/unwatch take optional_yield
Signed-off-by: Casey Bodley <[email protected]>
1 parent 4e455f0 commit d0499ae

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

src/rgw/driver/rados/rgw_tools.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,34 @@ int rgw_get_rados_ref(const DoutPrefixProvider* dpp, librados::Rados* rados,
116116
return 0;
117117
}
118118

119+
int rgw_rados_ref::watch(const DoutPrefixProvider* dpp, uint64_t* handle,
120+
librados::WatchCtx2* ctx, optional_yield y)
121+
{
122+
if (y) {
123+
auto& yield = y.get_yield_context();
124+
boost::system::error_code ec;
125+
librados::async_watch(yield.get_executor(), ioctx, obj.oid,
126+
handle, ctx, 0, yield[ec]);
127+
return ceph::from_error_code(ec);
128+
} else {
129+
maybe_warn_about_blocking(dpp);
130+
return ioctx.watch2(obj.oid, handle, ctx);
131+
}
132+
}
133+
134+
int rgw_rados_ref::unwatch(const DoutPrefixProvider* dpp, uint64_t handle,
135+
optional_yield y)
136+
{
137+
if (y) {
138+
auto& yield = y.get_yield_context();
139+
boost::system::error_code ec;
140+
librados::async_unwatch(yield.get_executor(), ioctx, handle, yield[ec]);
141+
return ceph::from_error_code(ec);
142+
} else {
143+
maybe_warn_about_blocking(dpp);
144+
return ioctx.unwatch2(handle);
145+
}
146+
}
119147

120148
map<string, bufferlist>* no_change_attrs() {
121149
static map<string, bufferlist> no_change;

src/rgw/driver/rados/rgw_tools.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,10 @@ struct rgw_rados_ref {
128128
return ioctx.aio_operate(obj.oid, c, op, pbl);
129129
}
130130

131-
int watch(uint64_t* handle, librados::WatchCtx2* ctx) {
132-
return ioctx.watch2(obj.oid, handle, ctx);
133-
}
134-
135-
int aio_watch(librados::AioCompletion* c, uint64_t* handle,
136-
librados::WatchCtx2 *ctx) {
137-
return ioctx.aio_watch(obj.oid, c, handle, ctx);
138-
}
131+
int watch(const DoutPrefixProvider* dpp, uint64_t* handle,
132+
librados::WatchCtx2* ctx, optional_yield y);
139133

140-
int unwatch(uint64_t handle) {
141-
return ioctx.unwatch2(handle);
142-
}
134+
int unwatch(const DoutPrefixProvider* dpp, uint64_t handle, optional_yield y);
143135

144136
int notify(const DoutPrefixProvider* dpp, bufferlist& bl, uint64_t timeout_ms,
145137
bufferlist* pbl, optional_yield y) {

0 commit comments

Comments
 (0)