object_t oid;
librados::WatchCtx *ctx;
librados::WatchCtx2 *ctx2;
+ bool internal = false;
WatchInfo(librados::IoCtxImpl *io, object_t o,
- librados::WatchCtx *c, librados::WatchCtx2 *c2)
- : ioctx(io), oid(o), ctx(c), ctx2(c2) {
+ librados::WatchCtx *c, librados::WatchCtx2 *c2,
+ bool inter)
+ : ioctx(io), oid(o), ctx(c), ctx2(c2), internal(inter) {
ioctx->get();
}
~WatchInfo() {
ioctx->put();
+ if (internal) {
+ delete ctx;
+ delete ctx2;
+ }
}
void handle_notify(uint64_t notify_id,
}
};
-int librados::IoCtxImpl::watch(const object_t& oid,
- uint64_t *handle,
- librados::WatchCtx *ctx,
- librados::WatchCtx2 *ctx2)
+int librados::IoCtxImpl::watch(const object_t& oid, uint64_t *handle,
+ librados::WatchCtx *ctx,
+ librados::WatchCtx2 *ctx2,
+ bool internal)
{
::ObjectOperation wr;
version_t objver;
Objecter::LingerOp *linger_op = objecter->linger_register(oid, oloc, 0);
*handle = linger_op->get_cookie();
linger_op->watch_context = new WatchInfo(this,
- oid, ctx, ctx2);
+ oid, ctx, ctx2, internal);
prepare_assert_ops(&wr);
wr.watch(*handle, CEPH_OSD_WATCH_OP_WATCH);
AioCompletionImpl *c,
uint64_t *handle,
librados::WatchCtx *ctx,
- librados::WatchCtx2 *ctx2)
+ librados::WatchCtx2 *ctx2,
+ bool internal)
{
Objecter::LingerOp *linger_op = objecter->linger_register(oid, oloc, 0);
c->io = this;
version_t objver;
*handle = linger_op->get_cookie();
- linger_op->watch_context = new WatchInfo(this, oid, ctx, ctx2);
+ linger_op->watch_context = new WatchInfo(this, oid, ctx, ctx2, internal);
prepare_assert_ops(&wr);
wr.watch(*handle, CEPH_OSD_WATCH_OP_WATCH);
void set_sync_op_version(version_t ver);
int watch(const object_t& oid, uint64_t *cookie, librados::WatchCtx *ctx,
- librados::WatchCtx2 *ctx2);
+ librados::WatchCtx2 *ctx2, bool internal = false);
int aio_watch(const object_t& oid, AioCompletionImpl *c, uint64_t *cookie,
- librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2);
+ librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2,
+ bool internal = false);
int watch_check(uint64_t cookie);
int unwatch(uint64_t cookie);
int aio_unwatch(uint64_t cookie, AioCompletionImpl *c);
librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
object_t oid(o);
C_WatchCB *wc = new C_WatchCB(watchcb, arg);
- int retval = ctx->watch(oid, cookie, wc, NULL);
+ int retval = ctx->watch(oid, cookie, wc, NULL, true);
tracepoint(librados, rados_watch_exit, retval, *handle);
return retval;
}
librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
object_t oid(o);
C_WatchCB2 *wc = new C_WatchCB2(watchcb, watcherrcb, arg);
- ret = ctx->watch(oid, cookie, NULL, wc);
+ ret = ctx->watch(oid, cookie, NULL, wc, true);
}
tracepoint(librados, rados_watch_exit, ret, handle ? *handle : 0);
return ret;
librados::AioCompletionImpl *c =
reinterpret_cast<librados::AioCompletionImpl*>(completion);
C_WatchCB2 *wc = new C_WatchCB2(watchcb, watcherrcb, arg);
- ret = ctx->aio_watch(oid, c, cookie, NULL, wc);
+ ret = ctx->aio_watch(oid, c, cookie, NULL, wc, true);
}
tracepoint(librados, rados_watch_exit, ret, handle ? *handle : 0);
return ret;