Notify::Notify(
ConnectionRef client,
uint64_t client_gid,
- unsigned num_watchers,
bufferlist &payload,
uint32_t timeout,
uint64_t cookie,
uint64_t version,
OSDService *osd)
: client(client), client_gid(client_gid),
- in_progress_watchers(num_watchers),
complete(false),
discarded(false),
timed_out(false),
NotifyRef Notify::makeNotifyRef(
ConnectionRef client,
uint64_t client_gid,
- unsigned num_watchers,
bufferlist &payload,
uint32_t timeout,
uint64_t cookie,
OSDService *osd) {
NotifyRef ret(
new Notify(
- client, client_gid, num_watchers,
+ client, client_gid,
payload, timeout,
cookie, notify_id,
version, osd));
return;
}
- in_progress_watchers = 0; // we give up
timed_out = true; // we will send the client an error code
maybe_complete_notify();
assert(complete);
dout(10) << "complete_watcher" << dendl;
if (is_discarded())
return;
- assert(in_progress_watchers > 0);
+ assert(watchers.count(watch));
watchers.erase(watch);
- --in_progress_watchers;
notify_replies.insert(make_pair(watch->get_watcher_gid(), reply_bl));
maybe_complete_notify();
}
dout(10) << __func__ << dendl;
if (is_discarded())
return;
- assert(in_progress_watchers > 0);
+ assert(watchers.count(watch));
watchers.erase(watch);
- --in_progress_watchers;
maybe_complete_notify();
}
void Notify::maybe_complete_notify()
{
dout(10) << "maybe_complete_notify -- "
- << in_progress_watchers
+ << watchers.size()
<< " in progress watchers " << dendl;
- if (!in_progress_watchers) {
+ if (watchers.empty() || timed_out) {
bufferlist bl;
::encode(notify_replies, bl);
bufferlist empty;
Mutex::Locker l(lock);
register_cb();
maybe_complete_notify();
- assert(in_progress_watchers == watchers.size());
}
#define dout_subsys ceph_subsys_osd
WNotifyRef self;
ConnectionRef client;
uint64_t client_gid;
- unsigned in_progress_watchers;
bool complete;
bool discarded;
bool timed_out; ///< true if the notify timed out
return discarded || complete;
}
- /// Sends notify completion if in_progress_watchers == 0
+ /// Sends notify completion if watchers.empty() or timeout
void maybe_complete_notify();
/// Called on Notify timeout
Notify(
ConnectionRef client,
uint64_t client_gid,
- unsigned num_watchers,
bufferlist &payload,
uint32_t timeout,
uint64_t cookie,
string gen_dbg_prefix() {
stringstream ss;
ss << "Notify(" << make_pair(cookie, notify_id) << " "
- << " in_progress_watchers=" << in_progress_watchers
+ << " watchers=" << watchers.size()
<< ") ";
return ss.str();
}
static NotifyRef makeNotifyRef(
ConnectionRef client,
uint64_t client_gid,
- unsigned num_watchers,
bufferlist &payload,
uint32_t timeout,
uint64_t cookie,