]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
neorados: On watch error, go through safe cookie interface to cancel
authorAdam C. Emerson <aemerson@redhat.com>
Wed, 26 Nov 2025 05:54:55 +0000 (00:54 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Fri, 5 Dec 2025 18:08:33 +0000 (13:08 -0500)
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 <aemerson@redhat.com>
src/neorados/RADOS.cc

index fb59c55c07fd80bf7c6649b9ccc84ae3761f5668..06179077736c88206488630fce8c395d4e5ec802 100644 (file)
@@ -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);