socketpool 0.1.0 → 0.1.1
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/VERSION +1 -1
- data/lib/socketpool.rb +11 -7
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/socketpool.rb
CHANGED
@@ -58,18 +58,22 @@ class SocketPool
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# Return a socket to the pool.
|
61
|
-
|
61
|
+
# Allow for destroying a resetting socket if the application determines the connection is no good
|
62
|
+
def checkin(socket, reset=false)
|
62
63
|
@connection_mutex.synchronize do
|
63
|
-
|
64
|
+
if reset
|
65
|
+
@socket.delete(socket)
|
66
|
+
@checked_out.delete(socket)
|
67
|
+
socket = checkout_new_socket
|
68
|
+
end
|
69
|
+
|
70
|
+
@checked_out.delete(socket)
|
64
71
|
@queue.signal
|
65
72
|
end
|
66
73
|
true
|
67
|
-
end
|
74
|
+
end
|
68
75
|
|
69
76
|
# Adds a new socket to the pool and checks it out.
|
70
|
-
#
|
71
|
-
# This method is called exclusively from #checkout;
|
72
|
-
# therefore, it runs within a mutex.
|
73
77
|
def checkout_new_socket
|
74
78
|
begin
|
75
79
|
socket = Socket.new(so_domain(@socktype), so_type(@socktype), 0)
|
@@ -83,9 +87,9 @@ class SocketPool
|
|
83
87
|
raise ConnectionFailure, "Failed to connect to host #{@host} and port #{@port}: #{ex}"
|
84
88
|
end
|
85
89
|
|
90
|
+
@checked_out << socket
|
86
91
|
@sockets << socket
|
87
92
|
@pids[socket] = Process.pid
|
88
|
-
@checked_out << socket
|
89
93
|
socket
|
90
94
|
end
|
91
95
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socketpool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brandon Dewitt
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-17 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|