OpType op;
+ bool used;
+
req_context() : complete(false), status(S3StatusOK), ctx(NULL), cb(NULL), arg(NULL), in_bl(NULL), off(0), len(0),
- lock("req_context"), bucket_ctx(NULL), should_destroy_ctx(false), op(OP_NONE) {}
+ lock("req_context"), bucket_ctx(NULL), should_destroy_ctx(false), op(OP_NONE), used(false) {}
~req_context() {
if (should_destroy_ctx) {
S3_destroy_request_context(ctx);
struct req_context *ctx = (struct req_context *)cb_data;
ctx->lock.Lock();
- ctx->complete = true;
ctx->status = status;
ctx->lock.Unlock();
}
ctx->lock.Lock();
+ ctx->complete = true;
ctx->cond.SignalAll();
ctx->lock.Unlock();
handles = NULL;
}
int create_completion(int slot, void (*cb)(void *, void*), void *arg) {
+ assert (!completions[slot]);
+
struct req_context *ctx = new req_context;
ctx->ctx = handles[slot];
+ assert (!ctx->used);
+ ctx->used = true;
ctx->cb = cb;
ctx->arg = arg;
void release_completion(int slot) {
struct req_context *ctx = completions[slot];
+ ctx->used = false;
+
ctx->put();
completions[slot] = 0;
}