bunny 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.md +9 -0
- data/lib/bunny/reader_loop.rb +6 -0
- data/lib/bunny/session.rb +27 -7
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/connection_stop_spec.rb +9 -6
- metadata +1 -1
data/ChangeLog.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## Changes between Bunny 0.9.5 and 0.9.6
|
2
|
+
|
3
|
+
### Eliminated Race Condition in Bunny::Session#close
|
4
|
+
|
5
|
+
`Bunny::Session#close` had a race condition that caused (non-deterministic)
|
6
|
+
exceptions when connection transport was closed before connection
|
7
|
+
reader loop was guaranteed to have stopped.
|
8
|
+
|
9
|
+
|
1
10
|
## Changes between Bunny 0.9.4 and 0.9.5
|
2
11
|
|
3
12
|
### connection.close Raises Exceptions on Connection Thread
|
data/lib/bunny/reader_loop.rb
CHANGED
@@ -51,6 +51,8 @@ module Bunny
|
|
51
51
|
@session_thread.raise(Bunny::NetworkFailure.new("caught an unexpected exception in the network loop: #{e.message}", e))
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
@stopped = true
|
54
56
|
end
|
55
57
|
|
56
58
|
def run_once
|
@@ -80,6 +82,10 @@ module Bunny
|
|
80
82
|
@stopping = true
|
81
83
|
end
|
82
84
|
|
85
|
+
def stopped?
|
86
|
+
@stopped = true
|
87
|
+
end
|
88
|
+
|
83
89
|
def kill
|
84
90
|
@thread.kill
|
85
91
|
@thread.join
|
data/lib/bunny/session.rb
CHANGED
@@ -259,8 +259,13 @@ module Bunny
|
|
259
259
|
close_all_channels
|
260
260
|
|
261
261
|
Bunny::Timer.timeout(@transport.disconnect_timeout, ClientTimeout) do
|
262
|
-
self.close_connection(
|
262
|
+
self.close_connection(true)
|
263
263
|
end
|
264
|
+
|
265
|
+
maybe_shutdown_reader_loop
|
266
|
+
close_transport
|
267
|
+
|
268
|
+
@status = :closed
|
264
269
|
end
|
265
270
|
end
|
266
271
|
alias stop close
|
@@ -399,11 +404,6 @@ module Bunny
|
|
399
404
|
@last_connection_close_ok = method
|
400
405
|
begin
|
401
406
|
@continuations.clear
|
402
|
-
|
403
|
-
reader_loop.stop
|
404
|
-
@reader_loop = nil
|
405
|
-
|
406
|
-
@transport.close
|
407
407
|
rescue StandardError => e
|
408
408
|
@logger.error e.class.name
|
409
409
|
@logger.error e.message
|
@@ -617,7 +617,27 @@ module Bunny
|
|
617
617
|
|
618
618
|
# @private
|
619
619
|
def maybe_shutdown_reader_loop
|
620
|
-
|
620
|
+
if @reader_loop
|
621
|
+
@reader_loop.stop
|
622
|
+
# We don't need to kill the loop but
|
623
|
+
# this is the easiest way to wait until the loop
|
624
|
+
# is guaranteed to have terminated
|
625
|
+
@reader_loop.kill
|
626
|
+
end
|
627
|
+
|
628
|
+
@reader_loop = nil
|
629
|
+
end
|
630
|
+
|
631
|
+
# @private
|
632
|
+
def close_transport
|
633
|
+
begin
|
634
|
+
@transport.close
|
635
|
+
rescue StandardError => e
|
636
|
+
@logger.error "Exception when closing transport:"
|
637
|
+
@logger.error e.class.name
|
638
|
+
@logger.error e.message
|
639
|
+
@logger.error e.backtrace
|
640
|
+
end
|
621
641
|
end
|
622
642
|
|
623
643
|
# @private
|
data/lib/bunny/version.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Bunny::Session do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
4000.times do |i|
|
5
|
+
it "can be closed (take #{i})" do
|
6
|
+
c = Bunny.new(:automatically_recover => false)
|
7
|
+
c.start
|
8
|
+
ch = c.create_channel
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
c.should be_connected
|
11
|
+
c.stop
|
12
|
+
c.should be_closed
|
13
|
+
end
|
11
14
|
end
|
12
15
|
end
|