socket_duplex 1.1.11 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/socket_duplex.rb +10 -25
- data/socket_duplex.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18de23c973bd33d6e9cea5bd88e302867b12d8c5
|
4
|
+
data.tar.gz: de3ef17ca8464a474075960b5e942dcf243a3519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40fd07b60069e41acf5dfbe5f932ced6883ead3b96e5616923fc861782ffd0197a8ae0923c44e525822b9044ed8a461cc96558d63d7237830d20a4af111fe497
|
7
|
+
data.tar.gz: 841a1c506013112b670cc9e490231dd81631f75be1215d5330aa13f391e4824171685f37d08641ebf675d9da51defd8c9d93d690203e839a5966b2f65f831efc
|
data/lib/socket_duplex.rb
CHANGED
@@ -18,8 +18,6 @@ module Rack
|
|
18
18
|
#@queue = SizedQueue.new(MAX_QUEUE_SIZE)
|
19
19
|
@threads_to_sockets = {}
|
20
20
|
#Thread.new { activate_workers() }
|
21
|
-
Rails.logger.info "Process id: " + Process.pid.to_s
|
22
|
-
Rails.logger.info "Init"
|
23
21
|
rescue nil
|
24
22
|
end
|
25
23
|
end
|
@@ -29,8 +27,6 @@ module Rack
|
|
29
27
|
if !defined? @queue
|
30
28
|
@queue = SizedQueue.new(MAX_QUEUE_SIZE)
|
31
29
|
activate_workers()
|
32
|
-
Rails.logger.info "Process id: " + Process.pid.to_s
|
33
|
-
Rails.logger.info "Init queue"
|
34
30
|
end
|
35
31
|
dup._call(env)
|
36
32
|
rescue nil
|
@@ -59,10 +55,7 @@ module Rack
|
|
59
55
|
begin
|
60
56
|
env = @queue.pop
|
61
57
|
if env
|
62
|
-
Rails.logger.info "Process id: " + Process.pid.to_s
|
63
|
-
Rails.logger.info "Connecting"
|
64
58
|
connect_to_ws(Thread.current)
|
65
|
-
Rails.logger.info "Sending"
|
66
59
|
handle_request(env)
|
67
60
|
end
|
68
61
|
rescue nil
|
@@ -95,24 +88,16 @@ module Rack
|
|
95
88
|
|
96
89
|
def handle_request(env)
|
97
90
|
request_hash = {}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
rescue Exception => e
|
109
|
-
Rails.logger.info "Error sending"
|
110
|
-
if ws
|
111
|
-
ws.close()
|
112
|
-
end rescue nil
|
113
|
-
@threads_to_sockets[Thread.current] = nil
|
114
|
-
end
|
115
|
-
end rescue nil
|
91
|
+
write_env(request_hash, env)
|
92
|
+
ws = @threads_to_sockets[Thread.current]
|
93
|
+
begin
|
94
|
+
ws.send request_hash.to_json
|
95
|
+
rescue Exception => e
|
96
|
+
if ws
|
97
|
+
ws.close()
|
98
|
+
end rescue nil
|
99
|
+
@threads_to_sockets[Thread.current] = nil
|
100
|
+
end
|
116
101
|
end
|
117
102
|
|
118
103
|
def write_env(request_hash, env)
|
data/socket_duplex.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "socket_duplex"
|
6
|
-
spec.version = '1.1.
|
6
|
+
spec.version = '1.1.12'
|
7
7
|
spec.authors = ["Secful"]
|
8
8
|
spec.description = %q{Rack middleware that duplexes HTTP traffic}
|
9
9
|
spec.summary = spec.description
|