#define dout_subsys ceph_subsys_rgw
bool RGWAsyncRadosProcessor::RGWWQ::_enqueue(RGWAsyncRadosRequest *req) {
+ req->get();
processor->m_req_queue.push_back(req);
dout(20) << "enqueued request req=" << hex << req << dec << dendl;
_dump_queue();
void RGWAsyncRadosProcessor::stop() {
m_tp.drain(&req_wq);
m_tp.stop();
+ for (auto iter = m_req_queue.begin(); iter != m_req_queue.end(); ++iter) {
+ (*iter)->put();
+ }
}
void RGWAsyncRadosProcessor::handle_request(RGWAsyncRadosRequest *req) {
req->send_request();
+ req->put();
}
void RGWAsyncRadosProcessor::queue(RGWAsyncRadosRequest *req) {
RGWSimpleRadosLockCR::~RGWSimpleRadosLockCR()
{
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int RGWSimpleRadosLockCR::send_request()
RGWSimpleRadosUnlockCR::~RGWSimpleRadosUnlockCR()
{
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int RGWSimpleRadosUnlockCR::send_request()
#include "common/WorkQueue.h"
#include "common/Throttle.h"
-class RGWAsyncRadosRequest {
+class RGWAsyncRadosRequest : public RefCountedObject {
RGWAioCompletionNotifier *notifier;
void *user_info;
int retcode;
+ bool done;
+
+ Mutex lock;
+
protected:
virtual int _send_request() = 0;
public:
- RGWAsyncRadosRequest(RGWAioCompletionNotifier *_cn) : notifier(_cn) {}
+ RGWAsyncRadosRequest(RGWAioCompletionNotifier *_cn) : notifier(_cn), done(false), lock("RGWAsyncRadosRequest::lock") {}
virtual ~RGWAsyncRadosRequest() {}
void send_request() {
retcode = _send_request();
- notifier->cb();
+ {
+ Mutex::Locker l(lock);
+ if (!done) {
+ notifier->cb();
+ }
+ }
}
int get_ret_status() { return retcode; }
+
+ void finish() {
+ {
+ Mutex::Locker l(lock);
+ done = true;
+ }
+ put();
+ }
};
req(NULL) { }
~RGWSimpleRadosReadCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request();
req(NULL) { }
~RGWSimpleRadosReadAttrsCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request();
}
~RGWSimpleRadosWriteCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request() {
async_rados(_async_rados),
store(_store),
pool(_pool), oid(_oid),
- attrs(_attrs) {
+ attrs(_attrs), req(NULL) {
}
~RGWSimpleRadosWriteAttrsCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request() {
RGWWaitCR(RGWAsyncRadosProcessor *_async_rados, CephContext *_cct,
Mutex *_lock, Cond *_cond,
int _secs) : RGWSimpleCoroutine(cct), cct(_cct),
- async_rados(_async_rados), lock(_lock), cond(_cond), secs(_secs) {
+ async_rados(_async_rados), lock(_lock), cond(_cond), secs(_secs), req(NULL) {
}
~RGWWaitCR() {
wakeup();
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request() {
bucket_name(_bucket_name), bucket_id(_bucket_id),
bucket_info(_bucket_info), req(NULL) {}
~RGWGetBucketInstanceInfoCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request() {
~RGWFetchRemoteObjCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request() {
key(_key),
versioned(_versioned),
versioned_epoch(_versioned_epoch),
- delete_marker(_delete_marker) {
+ delete_marker(_delete_marker), req(NULL) {
del_if_older = (_timestamp != NULL);
if (_timestamp) {
timestamp = *_timestamp;
}
~RGWRemoveObjCR() {
- delete req;
+ if (req) {
+ req->finish();
+ }
}
int send_request() {