Skip to content

Commit

Permalink
Merge d849e6a into 9c09b33
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Aug 25, 2022
2 parents 9c09b33 + d849e6a commit 6775dcf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ <h2><a name="history"></a>History</h2>
is now exported as <code>http.getcreatefunc()</code>. This allows to capture the socket used by the
request. When using streaming responses, for example with server-side-events, this can be used to modify
the timeouts, or for closing the stream.</li>
<li>Fix: empty queues were not destroyed properly and could prevent Copas from exiting</li>
</ul></dd>

<dt><strong>Copas 4.0.0</strong> [29/Jul/2022]</dt>
Expand Down
6 changes: 6 additions & 0 deletions src/copas/queue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ function Queue:stop()
self.stopping = true
self.lock = Lock.new()
self.lock:get() -- close the lock
if self:get_size() == 0 then
-- queue is already empty, so "pop" function cannot call destroy on next
-- pop, so destroy now.
self:destroy()
end
end
return true
end
Expand Down Expand Up @@ -125,6 +130,7 @@ do
if self.lock then
self.lock:destroy()
end
self.sema:destroy()
setmetatable(self, destroyed_queue_mt)
return true
end
Expand Down

0 comments on commit 6775dcf

Please sign in to comment.