pyocf: fix management queue stop/put

Queue is stopped when reference counter drops to 0, so no need to
manually stop management queue after cache stop - simple put is
enough.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2019-04-25 13:10:27 -04:00
parent bb6fe41b9d
commit 93c8932a17
2 changed files with 6 additions and 7 deletions

View File

@ -167,7 +167,7 @@ class Cache:
self.owner.caches.append(self)
self.mngt_queue = mngt_queue or Queue(
self, "mgmt-{}".format(self.get_name()), mngt_queue=True
self, "mgmt-{}".format(self.get_name())
)
if default_io_queue:
@ -490,7 +490,7 @@ class Cache:
self.put_and_write_unlock()
raise OcfError("Failed stopping cache", c.results["error"])
self.mngt_queue.stop()
self.mngt_queue.put()
del self.io_queues[:]
self.started = False

View File

@ -36,11 +36,10 @@ def io_queue_run(*, queue: Queue, kick: Condition, stop: Event):
if stop.is_set() and not OcfLib.getInstance().ocf_queue_pending_io(queue):
break
class Queue:
_instances_ = {}
def __init__(self, cache, name, mngt_queue: bool = False):
def __init__(self, cache, name):
self.ops = QueueOps(kick=type(self)._kick, stop=type(self)._stop)
@ -67,7 +66,6 @@ class Queue:
},
)
self.thread.start()
self.mngt_queue = mngt_queue
@classmethod
def get_instance(cls, ref):
@ -95,12 +93,13 @@ class Queue:
with self.kick_condition:
self.kick_condition.notify_all()
def put(self):
OcfLib.getInstance().ocf_queue_put(self)
def stop(self):
with self.kick_condition:
self.stop_event.set()
self.kick_condition.notify_all()
self.thread.join()
if self.mngt_queue:
OcfLib.getInstance().ocf_queue_put(self)