serverengine 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2daf0f4af407a699df75677a6cdfdaa798b6c870acd77ee75bdaced9c3944eb7
4
- data.tar.gz: 40d6299f178209b2207966ceea322f1b36efef63f897a54f0a815fb28a2af71d
3
+ metadata.gz: c37776b7f6420e895262df160ce7156bf00b6c3adaccd8af016e2d35c2d49f28
4
+ data.tar.gz: 7109cb65899f1afd047c3a6ddce8dee6b51dcbf69d1c7bc0ef80937214a90850
5
5
  SHA512:
6
- metadata.gz: 95bd026a937bbf8ab666a9c89832e7c32d7b60c5a88ef91f61d08c6e6bf7595268e73c4eb03f09e972edd328f424304a17eb354d99e2caa7e14182f13bb76dd8
7
- data.tar.gz: 0f6a91d444ae252cc232bd1151804c706a43415388a23e65b8861cd53dc5ac3a490f557d14b6aebcda03d12371c5220e2f30859b2300a3124b03781650c8ec7f
6
+ metadata.gz: f92e476daba00bad71a9de2bb924187926bcc071266b510cba15741f584a3d14333d28533c9530d48f8b9820bd1fb9522bd1bfa5f3c1c858f238f44042a803cd
7
+ data.tar.gz: 0bd8378d0840b3ca89bae30999317925f9e3155d9c37fb3a9d5482c95f1be0350fa60b82c8d0706d5cdea40573f5bdf2801d4717f55b22da32469177895c15b5
data/.travis.yml CHANGED
@@ -1,13 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.1.10
5
- - 2.2.9
6
- - 2.3.8
7
4
  - 2.4.9
8
5
  - 2.5.7
9
6
  - 2.6.5
10
- - 2.7.0
7
+ - 2.7
11
8
  - ruby-head
12
9
 
13
10
  branches:
data/Changelog CHANGED
@@ -1,3 +1,7 @@
1
+ 2021-02-17 version 2.2.3:
2
+
3
+ * Change SocketManager's port assignment strategy on Windows
4
+
1
5
  2020-11-02 version 2.2.2:
2
6
 
3
7
  * Fix incomplete Windows support in spawn based multi worker
@@ -72,7 +72,10 @@ module ServerEngine
72
72
  class Server
73
73
  def self.generate_path
74
74
  if ServerEngine.windows?
75
- for port in 10000..65535
75
+ port = ENV['SERVERENGINE_SOCKETMANAGER_PORT']
76
+ return port.to_i if port
77
+
78
+ for port in get_dynamic_port_range
76
79
  if `netstat -na | findstr "#{port}"`.length == 0
77
80
  return port
78
81
  end
@@ -160,6 +163,40 @@ module ServerEngine
160
163
  ensure
161
164
  peer.close
162
165
  end
166
+
167
+ if ServerEngine.windows?
168
+ def self.valid_dynamic_port_range(start_port, end_port)
169
+ return false if start_port < 1025 or start_port > 65535
170
+ return false if end_port < 1025 or end_port > 65535
171
+ return false if start_port > end_port
172
+ true
173
+ end
174
+
175
+ def self.get_dynamic_port_range
176
+ numbers = []
177
+ # Example output of netsh (actual output is localized):
178
+ #
179
+ # Protocol tcp Dynamic Port Range
180
+ # ---------------------------------
181
+ # Start Port : 49152
182
+ # Number of Ports : 16384
183
+ #
184
+ str = `netsh int ipv4 show dynamicport tcp`.force_encoding("ASCII-8BIT")
185
+ str.each_line { |line| numbers << $1.to_i if line.match(/.*: (\d+)/) }
186
+
187
+ start_port, n_ports = numbers[0], numbers[1]
188
+ end_port = start_port + n_ports - 1
189
+
190
+ if valid_dynamic_port_range(start_port, end_port)
191
+ return start_port..end_port
192
+ else
193
+ # The default dynamic port range is 49152 - 65535 as of Windows Vista
194
+ # and Windows Server 2008.
195
+ # https://docs.microsoft.com/en-us/troubleshoot/windows-server/networking/default-dynamic-port-range-tcpip-chang
196
+ return 49152..65535
197
+ end
198
+ end
199
+ end
163
200
  end
164
201
 
165
202
  def self.send_peer(peer, obj)
@@ -1,3 +1,3 @@
1
1
  module ServerEngine
2
- VERSION = "2.2.2"
2
+ VERSION = "2.2.3"
3
3
  end
@@ -19,7 +19,21 @@ describe ServerEngine::SocketManager do
19
19
  File.unlink(server_path) if server_path.is_a?(String) && File.exist?(server_path)
20
20
  end
21
21
 
22
- if !ServerEngine.windows?
22
+ if ServerEngine.windows?
23
+ context 'Server.generate_path' do
24
+ it 'returns socket path as port number' do
25
+ path = SocketManager::Server.generate_path
26
+ expect(path).to be_between(49152, 65535)
27
+ end
28
+
29
+ it 'can be changed via environment variable' do
30
+ ENV['SERVERENGINE_SOCKETMANAGER_PORT'] = '54321'
31
+ path = SocketManager::Server.generate_path
32
+ expect(path).to be 54321
33
+ ENV.delete('SERVERENGINE_SOCKETMANAGER_PORT')
34
+ end
35
+ end
36
+ else
23
37
  context 'Server.generate_path' do
24
38
  it 'returns socket path under /tmp' do
25
39
  path = SocketManager::Server.generate_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-02 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sigdump
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.0.3
156
+ rubygems_version: 3.1.4
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: ServerEngine - multiprocess server framework