diff --git a/osd.cpp b/osd.cpp index 58099819..f1d67dd6 100644 --- a/osd.cpp +++ b/osd.cpp @@ -85,7 +85,12 @@ osd_t::~osd_t() bool osd_t::shutdown() { - // TODO + stopping = true; + if (inflight_ops > 0) + { + return false; + } + return bs->is_safe_to_stop(); } void osd_t::loop() @@ -314,6 +319,7 @@ void osd_t::handle_read(ring_data_t *data, int peer_fd) void osd_t::secondary_op_callback(osd_op_t *cur_op) { + inflight_ops--; auto cl_it = clients.find(cur_op->peer_fd); if (cl_it != clients.end()) { @@ -334,6 +340,13 @@ void osd_t::secondary_op_callback(osd_op_t *cur_op) void osd_t::enqueue_op(osd_op_t *cur_op) { + if (stopping) + { + // Throw operation away + delete cur_op; + return; + } + inflight_ops++; if (cur_op->op.hdr.magic != SECONDARY_OSD_OP_MAGIC || cur_op->op.hdr.opcode < OSD_OP_MIN || cur_op->op.hdr.opcode > OSD_OP_MAX || (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_READ || cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE) && diff --git a/osd.h b/osd.h index 95a908c6..0b0ab8bc 100644 --- a/osd.h +++ b/osd.h @@ -82,6 +82,8 @@ class osd_t // fields + bool stopping = false; + int inflight_ops = 0; blockstore_t *bs; ring_loop_t *ringloop;