// did we get a reply?
if (request->reply)
break;
-
}
// got it!
request->dispatch_cond->Signal();
dout(20) << "sendrecv kickback on tid " << tid << " " << request->dispatch_cond << dendl;
- // clean up.
- mds_requests.erase(tid);
- request->put(); //for the dumb data structure
-
-
// insert trace
utime_t from = request->sent_stamp;
Inode *target = insert_trace(request->get(), from, mds);
dout(20) << "handle_client_reply got a reply. Safe:" << reply->is_safe()
<< " tid:" << tid << dendl;
int mds_num = reply->get_source().num();
+ assert(mds_sessions.count(mds_num));
MetaRequest *request = mds_requests[tid]->get();
assert(request);
// store reply
- // if (!request->reply && !reply->is_safe()) //safe replies have no useful info
request->reply = reply;
if ((request->got_unsafe && !reply->is_safe())
//duplicate response
dout(0) << "got a duplicate reply on " << tid << " from mds "
<< mds_num << " safe:" << reply->is_safe() << dendl;
- request->put();
+ goto cleanup;
return;
}
cleanup:
request->put();
+ if(request->got_safe) {
+ mds_requests.erase(tid);
+ request->put(); //for the dumb data structure
+ }
}
private:
xlist<MetaRequest*>::item unsafe_item;
+ Mutex lock; //for get/set sync
public:
Cond *caller_cond; // who to take up
Cond *dispatch_cond; // who to kick back
resend_mds(-1), num_fwd(0), retry_attempt(0),
ref(1), reply(0),
got_safe(false), got_unsafe(false), unsafe_item(this),
+ lock("MetaRequest lock"),
caller_cond(0), dispatch_cond(0) { }
MetaRequest* get() {
+ lock.Lock();
++ref;
- cerr << "Get called on MetaRequest tid " << tid
- << "Refcount is " << ref
- << " Type is " << request->head.op << std::endl;
+ cout << "Get called on MetaRequest tid " << tid
+ << "Refcount is " << ref << std::endl;
+ lock.Unlock();
return this; }
void put() {
- cerr << "Put called on MetaRequest tid " << tid;
- if (--ref == 0) {
- cerr << "MetaRequest tid" << tid << " deleting." << std::endl;
+ lock.Lock();
+ cout << "Put called on MetaRequest tid " << tid;
+ --ref;
+ lock.Unlock();
+ if (ref == 0) {
+ cout << "MetaRequest tid" << tid << " deleting." << std::endl;
delete this;
}
- cerr << "Refcount is " << ref
- << " Type is " << request->head.op << std::endl;
+ cout << "Refcount is " << ref << std::endl;
}
xlist<MetaRequest*>::item * get_meta_item() {