From 7a2ec05cc8c11e948ff62fe07c00df8692a50b50 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 10 Aug 2014 17:52:18 -0700 Subject: [PATCH] osd: include ETIMEDOUT in notify reply on timeout If a notify operation times out (all watchers to not ACK in time), include an ETIMEDOUT in the final error message back to the client, so that they know about it. Signed-off-by: Sage Weil --- src/osd/Watch.cc | 6 +++++- src/osd/Watch.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 4fdb124602000..7b324957ef005 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -39,6 +39,7 @@ Notify::Notify( in_progress_watchers(num_watchers), complete(false), discarded(false), + timed_out(false), payload(payload), timeout(timeout), cookie(cookie), @@ -97,7 +98,8 @@ void Notify::do_timeout() return; } - in_progress_watchers = 0; // we give up TODO: we should return an error code + in_progress_watchers = 0; // we give up + timed_out = true; // we will send the client and error code maybe_complete_notify(); assert(complete); set _watchers; @@ -170,6 +172,8 @@ void Notify::maybe_complete_notify() if (!in_progress_watchers) { MWatchNotify *reply(new MWatchNotify(cookie, version, notify_id, WATCH_NOTIFY, payload)); + if (timed_out) + reply->return_code = -ETIMEDOUT; osd->send_message_osd_client(reply, client.get()); unregister_cb(); complete = true; diff --git a/src/osd/Watch.h b/src/osd/Watch.h index e2cbfc1b6870d..ceae6ad0edc34 100644 --- a/src/osd/Watch.h +++ b/src/osd/Watch.h @@ -58,6 +58,7 @@ class Notify { unsigned in_progress_watchers; bool complete; bool discarded; + bool timed_out; ///< true if the notify timed out set watchers; bufferlist payload; -- 2.39.5