Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #353 from dblock/fix-345
Browse files Browse the repository at this point in the history
Fix + spec for #345.
  • Loading branch information
arthurnn committed Feb 12, 2015
2 parents 6a58755 + f9905ff commit 265503d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Overview

## Next

### Resolved Issues

* \#345
Writes fail with ConnectionPool::PoolShuttingDownError. (fedenusy, dblock)

## 2.0.3

### Resolved Issues
Expand Down
4 changes: 2 additions & 2 deletions lib/moped/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ def disconnect
#
# @since 2.0.0
def down!
@pool = Connection::Manager.shutdown(self)
@down_at = Time.new
@pool = nil
@latency = nil
true
Connection::Manager.shutdown(self)
end

# Yields the block if a connection can be established, retrying when a
Expand Down
32 changes: 25 additions & 7 deletions spec/moped/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,33 @@
end
end

pending '#down!' do
describe '#down!' do
describe 'when connected' do
before do
node.connected?
end

before do
node.connected?
node.down!
end
describe 'shutdown' do
before do
node.down!
end

it 'clears out the connection pool' do
expect(node.instance_variable_get(:@pool)).to be_nil
it 'clears out the connection pool' do
expect(node.instance_variable_get(:@pool)).to be_nil
end
end

describe 'shutdown from multiple threads' do
before do
# fake the behavior of @pool that holds its value until shutdown returns
allow(Moped::Connection::Manager).to receive(:shutdown).and_return(node.instance_variable_get(:@pool)).once
node.down!
end

it 'clears out the connection pool before returning' do
expect(node.instance_variable_get(:@pool)).to be_nil
end
end
end
end

Expand Down

0 comments on commit 265503d

Please sign in to comment.