nonnative 3.2.0 → 3.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3015cc7b1f784a45dbb77184fd73e67e6cf33ff9d7bb97d09ebd01f1359d85b9
4
- data.tar.gz: 9bf8f2fc9bb72f8de89e76f44912d62e8a7cd19ccb533c7930600fbc70411b28
3
+ metadata.gz: 522cec08aee3855943f6ef6ba38bec3d85acd00aeeb2d6640a6869cf55014518
4
+ data.tar.gz: ebebc8d342a2111f8fb8538c0bf5b615c549b61127761c3e2ada47397294b47c
5
5
  SHA512:
6
- metadata.gz: 73147dafad8a271673d070f033a1a3f92270994b0593bb7f391d0ae126ed0e34005cfd22af9e01052846bd757b866fba9db4d36a3468219be54208e8121a5f80
7
- data.tar.gz: ad58bc0015ccdf3f91f9ffbb5ca12de3bd9650d540ef33ec982df353abd6892c496328815f60991e340721971e1bfbf86a663292337a755280d1157c2ff9d5be
6
+ metadata.gz: e4df243398b167fb955324fe12894f8bb5ecaf4ec612f8c55ad73e6cf95d6e04868ad1ee2ff64c1fbbc68322ea96dc953a0329b01f609a31b5409fb38542f09a
7
+ data.tar.gz: 419ca92810588c41e281cd4d77e49651bee8c412d7285689f196c176473364f1562eabbe1944a121e238e79c9cfb0de6335bbcde05b6e068478c45db4414cef2
data/.circleci/config.yml CHANGED
@@ -35,7 +35,7 @@ jobs:
35
35
  resource_class: arm.large
36
36
  sync:
37
37
  docker:
38
- - image: alexfalkowski/release:8.14
38
+ - image: alexfalkowski/release:8.15
39
39
  working_directory: ~/nonnative
40
40
  steps:
41
41
  - checkout:
@@ -46,7 +46,7 @@ jobs:
46
46
  resource_class: arm.large
47
47
  version:
48
48
  docker:
49
- - image: alexfalkowski/release:8.14
49
+ - image: alexfalkowski/release:8.15
50
50
  working_directory: ~/nonnative
51
51
  steps:
52
52
  - checkout:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (3.2.0)
4
+ nonnative (3.2.1)
5
5
  concurrent-ruby (>= 1, < 2)
6
6
  config (>= 5, < 6)
7
7
  cucumber (>= 7, < 12)
@@ -77,18 +77,17 @@ module Nonnative
77
77
  #
78
78
  # @return [void]
79
79
  def stop
80
- mutex.synchronize do
81
- close_connections
82
- end
83
-
84
- server = @tcp_server
85
- @tcp_server = nil
80
+ server = tcp_server
86
81
  server&.close
87
82
 
88
- listener_thread = @thread
89
- @thread = nil
83
+ listener_thread = thread
90
84
  listener_thread&.join
91
85
 
86
+ @tcp_server = nil
87
+ @thread = nil
88
+
89
+ close_connections
90
+
92
91
  Nonnative.logger.info "stopped with host '#{service.host}' and port '#{service.port}' for proxy 'fault_injection'"
93
92
  end
94
93
 
@@ -162,7 +161,7 @@ module Nonnative
162
161
  logger.info "handled connection for '#{id}' with socket '#{socket.inspect}'"
163
162
  end
164
163
 
165
- connections.delete(id)
164
+ delete_connection(id)
166
165
  end
167
166
 
168
167
  def connect(id, socket)
@@ -179,24 +178,26 @@ module Nonnative
179
178
  end
180
179
 
181
180
  def close_connections
182
- connections.each do |id, connection|
181
+ active_connections = mutex.synchronize do
182
+ connections.to_a.tap { connections.clear }
183
+ end
184
+
185
+ active_connections.each do |id, connection|
183
186
  close_connection(id, connection)
184
187
  end
185
- ensure
186
- connections.clear
187
188
  end
188
189
 
189
190
  def apply_state(state)
190
- mutex.synchronize do
191
- Nonnative.logger.info "applying state '#{state}' for proxy 'fault_injection'"
191
+ Nonnative.logger.info "applying state '#{state}' for proxy 'fault_injection'"
192
192
 
193
+ mutex.synchronize do
193
194
  return if @state == state
194
195
 
195
196
  @state = state
196
- close_connections
197
-
198
- wait
199
197
  end
198
+
199
+ close_connections
200
+ wait
200
201
  end
201
202
 
202
203
  def read_state
@@ -204,15 +205,19 @@ module Nonnative
204
205
  end
205
206
 
206
207
  def register_connection(id, socket)
207
- connections[id] = Connection.new(socket)
208
+ mutex.synchronize { connections[id] = Connection.new(socket) }
208
209
  end
209
210
 
210
211
  def attach_connection_thread(id, thread)
211
- connections[id]&.thread = thread
212
+ mutex.synchronize { connections[id]&.thread = thread }
212
213
  end
213
214
 
214
215
  def attach_connection_pair(id, pair)
215
- connections[id]&.pair = pair
216
+ mutex.synchronize { connections[id]&.pair = pair }
217
+ end
218
+
219
+ def delete_connection(id)
220
+ mutex.synchronize { connections.delete(id) }
216
221
  end
217
222
 
218
223
  def close_connection(id, connection)
@@ -4,5 +4,5 @@ module Nonnative
4
4
  # The current gem version.
5
5
  #
6
6
  # @return [String]
7
- VERSION = '3.2.0'
7
+ VERSION = '3.2.1'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Falkowski