serverengine 2.2.0 → 2.2.1

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: 53e00b2c2ebec4b3f44d7afb6d519822bd215a94356d018d4de9c88b890ee944
4
- data.tar.gz: 667633c2ebcda531c78976fbaf6f86da06cf8c8ef17f1913679f02b2184715f2
3
+ metadata.gz: 934c5957de987807cb9a28cf740ee002cfa1c64d54c82b21acb16c464bfd8da0
4
+ data.tar.gz: aef6141bd22834eb0f9fb837d374ec69b5681cb31bddc0fa1afda5cd82c3ec38
5
5
  SHA512:
6
- metadata.gz: 4cd38c03f674b8c9826e11bf88969abcc8797d71fbeaf1630fbb779473bf276850a006a12f9e4b422de132a8087bfc38c477347d76b943cc120194b06878f64d
7
- data.tar.gz: 43a6c3773f01d987efb8724ffca4a604402cb0e1ab9bdb4ba3e13265e5820c169deca7720aabda780b7b34df7038191add977219a9d5bc84e0ba701ff17f3a95
6
+ metadata.gz: eb93190b271548e433d9dcc9ce2d7b4f8358a4bd96079b24c1417bc43e86567840733265df4931d79beacd1ba31dbe23bd1e29c1d205982e036dc29861d68c2a
7
+ data.tar.gz: '09f3589a04c3bbea01c619216066e7bbb9ac2e4414cd8345713315aa416cbe2600d537bec860034423bb4566881c5febc4efb33bfd28a376953c078aeee524fb'
data/Changelog CHANGED
@@ -1,3 +1,8 @@
1
+ 2020-01-24 version 2.2.1:
2
+
3
+ * Fix IPv6 dual-stack mode issue for UDP
4
+ * experimental: Add SERVERENGINE_USE_SOCKET_REUSEPORT envvar to enable SO_REUSEPORT
5
+
1
6
  2019-11-16 version 2.2.0:
2
7
 
3
8
  * Fix IPv6 dual-stack mode issue for TCP
@@ -50,21 +50,30 @@ module ServerEngine
50
50
  private
51
51
 
52
52
  def listen_tcp_new(bind_ip, port)
53
- # TCPServer.new doesn't set IPV6_V6ONLY flag, so use Addrinfo class instead.
54
- # TODO: make backlog configurable if necessary
55
- tsock = Addrinfo.tcp(bind_ip.to_s, port).listen(::Socket::SOMAXCONN)
56
- tsock.autoclose = false
57
- TCPServer.for_fd(tsock.fileno)
53
+ if ENV['SERVERENGINE_USE_SOCKET_REUSEPORT'] == '1'
54
+ # Based on Addrinfo#listen
55
+ tsock = Socket.new(bind_ip.ipv6? ? ::Socket::AF_INET6 : ::Socket::AF_INET, ::Socket::SOCK_STREAM, 0)
56
+ tsock.ipv6only! if bind_ip.ipv6?
57
+ tsock.setsockopt(:SOCKET, :REUSEPORT, true)
58
+ tsock.setsockopt(:SOCKET, :REUSEADDR, true)
59
+ tsock.bind(Addrinfo.tcp(bind_ip.to_s, port))
60
+ tsock.listen(::Socket::SOMAXCONN)
61
+ tsock.autoclose = false
62
+ TCPServer.for_fd(tsock.fileno)
63
+ else
64
+ # TCPServer.new doesn't set IPV6_V6ONLY flag, so use Addrinfo class instead.
65
+ # TODO: make backlog configurable if necessary
66
+ tsock = Addrinfo.tcp(bind_ip.to_s, port).listen(::Socket::SOMAXCONN)
67
+ tsock.autoclose = false
68
+ TCPServer.for_fd(tsock.fileno)
69
+ end
58
70
  end
59
71
 
60
72
  def listen_udp_new(bind_ip, port)
61
- if bind_ip.ipv6?
62
- sock = UDPSocket.new(Socket::AF_INET6)
63
- else
64
- sock = UDPSocket.new(Socket::AF_INET)
65
- end
66
- sock.bind(bind_ip.to_s, port)
67
- return sock
73
+ # UDPSocket.new doesn't set IPV6_V6ONLY flag, so use Addrinfo class instead.
74
+ usock = Addrinfo.udp(bind_ip.to_s, port).bind
75
+ usock.autoclose = false
76
+ UDPSocket.for_fd(usock.fileno)
68
77
  end
69
78
 
70
79
  def start_server(path)
@@ -1,3 +1,3 @@
1
1
  module ServerEngine
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -155,7 +155,27 @@ describe ServerEngine::SocketManager do
155
155
  test_state(:is_udp_socket).should == 1
156
156
  test_state(:udp_data_sent).should == 1
157
157
  end
158
- end if (TCPServer.open("::1",0) rescue nil)
158
+ end if (TCPServer.open("::1", 0) rescue nil)
159
+
160
+ unless ServerEngine.windows?
161
+ context 'using ipv4/ipv6' do
162
+ it 'can bind ipv4/ipv6 together' do
163
+ server = SocketManager::Server.open(server_path)
164
+ client = ServerEngine::SocketManager::Client.new(server_path)
165
+
166
+ tcp_v4 = client.listen_tcp('0.0.0.0', test_port)
167
+ udp_v4 = client.listen_udp('0.0.0.0', test_port)
168
+ tcp_v6 = client.listen_tcp('::', test_port)
169
+ udp_v6 = client.listen_udp('::', test_port)
170
+
171
+ tcp_v4.close
172
+ udp_v4.close
173
+ tcp_v6.close
174
+ udp_v6.close
175
+ server.close
176
+ end
177
+ end if (TCPServer.open("::", 0) rescue nil)
178
+ end
159
179
  end
160
180
 
161
181
  if ServerEngine.windows?
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.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-17 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sigdump