From 7c00e59207119be9aa45eb1928114bf495e343a4 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Wed, 26 Nov 2025 00:54:55 -0500 Subject: [PATCH] neorados: On watch error, go through safe cookie interface to cancel Possibly unnecessary defensive programming. At present I'm not sure of a way this could happen, possibly shutdown while `watch_()` is executing. In any case, adding a lookup to the error path isn't really a problem. Signed-off-by: Adam C. Emerson --- src/neorados/RADOS.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/neorados/RADOS.cc b/src/neorados/RADOS.cc index fb59c55c07f..06179077736 100644 --- a/src/neorados/RADOS.cc +++ b/src/neorados/RADOS.cc @@ -1530,13 +1530,15 @@ void RADOS::watch_(Object o, IOContext _ioc, auto e = asio::prefer(get_executor(), asio::execution::outstanding_work.tracked); impl->objecter->linger_watch( - linger_op, op, ioc->snapc, ceph::real_clock::now(), bl, - asio::bind_executor( - std::move(e), - [c = std::move(c), cookie, linger_op](bs::error_code e, cb::list) mutable { + linger_op, op, ioc->snapc, ceph::real_clock::now(), bl, + asio::bind_executor(std::move(e), [ + c = std::move(c), cookie, + objecter = impl->objecter](bs::error_code e, cb::list) mutable { if (e) { - linger_op->objecter->linger_cancel(linger_op); - cookie = 0; + if (auto linger_op = objecter->linger_by_cookie(cookie)) { + objecter->linger_cancel(linger_op.get()); + } + cookie = 0; } asio::dispatch(asio::append(std::move(c), e, cookie)); }), nullptr); @@ -1567,11 +1569,13 @@ void RADOS::watch_(Object o, IOContext _ioc, WatchComp c, linger_op, op, ioc->snapc, ceph::real_clock::now(), bl, asio::bind_executor( std::move(e), - [c = std::move(c), cookie, linger_op](bs::error_code e, cb::list) mutable { + [c = std::move(c), cookie, objecter = impl->objecter](bs::error_code e, cb::list) mutable { if (e) { - linger_op->user_data.reset(); - linger_op->objecter->linger_cancel(linger_op); - cookie = 0; + if (auto linger_op = objecter->linger_by_cookie(cookie)) { + linger_op->user_data.reset(); + objecter->linger_cancel(linger_op.get()); + } + cookie = 0; } asio::dispatch(asio::append(std::move(c), e, cookie)); }), nullptr); -- 2.47.3