Merge "Adding keep_idle config value to socket"
This commit is contained in:
commit
5d46c0d8b3
@ -57,6 +57,8 @@ IP address the account server should bind to. The default is 0.0.0.0 which will
|
|||||||
it bind to all available addresses.
|
it bind to all available addresses.
|
||||||
.IP "\fBbind_port\fR"
|
.IP "\fBbind_port\fR"
|
||||||
TCP port the account server should bind to. The default is 6202.
|
TCP port the account server should bind to. The default is 6202.
|
||||||
|
.IP "\fBkeep_idle\fR"
|
||||||
|
Value to set for socket TCP_KEEPIDLE. The default value is 600.
|
||||||
.IP "\fBbind_timeout\fR"
|
.IP "\fBbind_timeout\fR"
|
||||||
Timeout to bind socket. The default is 30.
|
Timeout to bind socket. The default is 30.
|
||||||
.IP \fBbacklog\fR
|
.IP \fBbacklog\fR
|
||||||
|
@ -57,6 +57,8 @@ IP address the container server should bind to. The default is 0.0.0.0 which wil
|
|||||||
it bind to all available addresses.
|
it bind to all available addresses.
|
||||||
.IP "\fBbind_port\fR"
|
.IP "\fBbind_port\fR"
|
||||||
TCP port the container server should bind to. The default is 6201.
|
TCP port the container server should bind to. The default is 6201.
|
||||||
|
.IP "\fBkeep_idle\fR"
|
||||||
|
Value to set for socket TCP_KEEPIDLE. The default value is 600.
|
||||||
.IP "\fBbind_timeout\fR"
|
.IP "\fBbind_timeout\fR"
|
||||||
Timeout to bind socket. The default is 30.
|
Timeout to bind socket. The default is 30.
|
||||||
.IP \fBbacklog\fR
|
.IP \fBbacklog\fR
|
||||||
|
@ -57,6 +57,8 @@ IP address the object server should bind to. The default is 0.0.0.0 which will m
|
|||||||
it bind to all available addresses.
|
it bind to all available addresses.
|
||||||
.IP "\fBbind_port\fR"
|
.IP "\fBbind_port\fR"
|
||||||
TCP port the object server should bind to. The default is 6200.
|
TCP port the object server should bind to. The default is 6200.
|
||||||
|
.IP "\fBkeep_idle\fR"
|
||||||
|
Value to set for socket TCP_KEEPIDLE. The default value is 600.
|
||||||
.IP "\fBbind_timeout\fR"
|
.IP "\fBbind_timeout\fR"
|
||||||
Timeout to bind socket. The default is 30.
|
Timeout to bind socket. The default is 30.
|
||||||
.IP \fBbacklog\fR
|
.IP \fBbacklog\fR
|
||||||
|
@ -56,6 +56,8 @@ IP address the proxy server should bind to. The default is 0.0.0.0 which will ma
|
|||||||
it bind to all available addresses.
|
it bind to all available addresses.
|
||||||
.IP "\fBbind_port\fR"
|
.IP "\fBbind_port\fR"
|
||||||
TCP port the proxy server should bind to. The default is 80.
|
TCP port the proxy server should bind to. The default is 80.
|
||||||
|
.IP "\fBkeep_idle\fR"
|
||||||
|
Value to set for socket TCP_KEEPIDLE. The default value is 600.
|
||||||
.IP "\fBbind_timeout\fR"
|
.IP "\fBbind_timeout\fR"
|
||||||
Timeout to bind socket. The default is 30.
|
Timeout to bind socket. The default is 30.
|
||||||
.IP \fBbacklog\fR
|
.IP \fBbacklog\fR
|
||||||
|
@ -437,6 +437,7 @@ mount_check true Whether or not check if the devices
|
|||||||
to the root device
|
to the root device
|
||||||
bind_ip 0.0.0.0 IP Address for server to bind to
|
bind_ip 0.0.0.0 IP Address for server to bind to
|
||||||
bind_port 6200 Port for server to bind to
|
bind_port 6200 Port for server to bind to
|
||||||
|
keep_idle 600 Value to set for socket TCP_KEEPIDLE
|
||||||
bind_timeout 30 Seconds to attempt bind before giving up
|
bind_timeout 30 Seconds to attempt bind before giving up
|
||||||
backlog 4096 Maximum number of allowed pending
|
backlog 4096 Maximum number of allowed pending
|
||||||
connections
|
connections
|
||||||
@ -1032,6 +1033,7 @@ mount_check true Whether or not check if the devices
|
|||||||
to the root device
|
to the root device
|
||||||
bind_ip 0.0.0.0 IP Address for server to bind to
|
bind_ip 0.0.0.0 IP Address for server to bind to
|
||||||
bind_port 6201 Port for server to bind to
|
bind_port 6201 Port for server to bind to
|
||||||
|
keep_idle 600 Value to set for socket TCP_KEEPIDLE
|
||||||
bind_timeout 30 Seconds to attempt bind before giving up
|
bind_timeout 30 Seconds to attempt bind before giving up
|
||||||
backlog 4096 Maximum number of allowed pending
|
backlog 4096 Maximum number of allowed pending
|
||||||
connections
|
connections
|
||||||
@ -1385,6 +1387,7 @@ mount_check true Whether or not check if the devices
|
|||||||
to the root device
|
to the root device
|
||||||
bind_ip 0.0.0.0 IP Address for server to bind to
|
bind_ip 0.0.0.0 IP Address for server to bind to
|
||||||
bind_port 6202 Port for server to bind to
|
bind_port 6202 Port for server to bind to
|
||||||
|
keep_idle 600 Value to set for socket TCP_KEEPIDLE
|
||||||
bind_timeout 30 Seconds to attempt bind before giving up
|
bind_timeout 30 Seconds to attempt bind before giving up
|
||||||
backlog 4096 Maximum number of allowed pending
|
backlog 4096 Maximum number of allowed pending
|
||||||
connections
|
connections
|
||||||
@ -1731,6 +1734,7 @@ Option Default Description
|
|||||||
bind_ip 0.0.0.0 IP Address for server to
|
bind_ip 0.0.0.0 IP Address for server to
|
||||||
bind to
|
bind to
|
||||||
bind_port 80 Port for server to bind to
|
bind_port 80 Port for server to bind to
|
||||||
|
keep_idle 600 Value to set for socket TCP_KEEPIDLE
|
||||||
bind_timeout 30 Seconds to attempt bind before
|
bind_timeout 30 Seconds to attempt bind before
|
||||||
giving up
|
giving up
|
||||||
backlog 4096 Maximum number of allowed pending
|
backlog 4096 Maximum number of allowed pending
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
# bind_ip = 0.0.0.0
|
# bind_ip = 0.0.0.0
|
||||||
bind_port = 6202
|
bind_port = 6202
|
||||||
|
# keep_idle = 600
|
||||||
# bind_timeout = 30
|
# bind_timeout = 30
|
||||||
# backlog = 4096
|
# backlog = 4096
|
||||||
# user = swift
|
# user = swift
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
# bind_ip = 0.0.0.0
|
# bind_ip = 0.0.0.0
|
||||||
bind_port = 6201
|
bind_port = 6201
|
||||||
|
# keep_idle = 600
|
||||||
# bind_timeout = 30
|
# bind_timeout = 30
|
||||||
# backlog = 4096
|
# backlog = 4096
|
||||||
# user = swift
|
# user = swift
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
# bind_ip = 0.0.0.0
|
# bind_ip = 0.0.0.0
|
||||||
bind_port = 6200
|
bind_port = 6200
|
||||||
|
# keep_idle = 600
|
||||||
# bind_timeout = 30
|
# bind_timeout = 30
|
||||||
# backlog = 4096
|
# backlog = 4096
|
||||||
# user = swift
|
# user = swift
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
# bind_ip = 0.0.0.0
|
# bind_ip = 0.0.0.0
|
||||||
bind_port = 8080
|
bind_port = 8080
|
||||||
|
# keep_idle = 600
|
||||||
# bind_timeout = 30
|
# bind_timeout = 30
|
||||||
# backlog = 4096
|
# backlog = 4096
|
||||||
# swift_dir = /etc/swift
|
# swift_dir = /etc/swift
|
||||||
|
@ -193,6 +193,14 @@ def get_socket(conf):
|
|||||||
bind_timeout = int(conf.get('bind_timeout', 30))
|
bind_timeout = int(conf.get('bind_timeout', 30))
|
||||||
retry_until = time.time() + bind_timeout
|
retry_until = time.time() + bind_timeout
|
||||||
warn_ssl = False
|
warn_ssl = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
keepidle = int(conf.get('keep_idle', 600))
|
||||||
|
if keepidle <= 0 or keepidle >= 2 ** 15 - 1:
|
||||||
|
raise ValueError()
|
||||||
|
except (ValueError, KeyError, TypeError):
|
||||||
|
raise ConfigFileError()
|
||||||
|
|
||||||
while not sock and time.time() < retry_until:
|
while not sock and time.time() < retry_until:
|
||||||
try:
|
try:
|
||||||
sock = listen(bind_addr, backlog=int(conf.get('backlog', 4096)),
|
sock = listen(bind_addr, backlog=int(conf.get('backlog', 4096)),
|
||||||
@ -214,7 +222,7 @@ def get_socket(conf):
|
|||||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 600)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, keepidle)
|
||||||
if warn_ssl:
|
if warn_ssl:
|
||||||
ssl_warning_message = _('WARNING: SSL should only be enabled for '
|
ssl_warning_message = _('WARNING: SSL should only be enabled for '
|
||||||
'testing purposes. Use external SSL '
|
'testing purposes. Use external SSL '
|
||||||
|
@ -404,6 +404,39 @@ class TestWSGI(unittest.TestCase):
|
|||||||
'keyfile': '',
|
'keyfile': '',
|
||||||
}
|
}
|
||||||
self.assertEqual(wsgi.ssl.wrap_socket_called, [expected_kwargs])
|
self.assertEqual(wsgi.ssl.wrap_socket_called, [expected_kwargs])
|
||||||
|
|
||||||
|
# test keep_idle value
|
||||||
|
keepIdle_value = 700
|
||||||
|
conf['keep_idle'] = keepIdle_value
|
||||||
|
sock = wsgi.get_socket(conf)
|
||||||
|
# assert
|
||||||
|
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||||
|
expected_socket_opts[socket.IPPROTO_TCP][
|
||||||
|
socket.TCP_KEEPIDLE] = keepIdle_value
|
||||||
|
self.assertEqual(sock.opts, expected_socket_opts)
|
||||||
|
|
||||||
|
# test keep_idle for str -> int conversion
|
||||||
|
keepIdle_value = '800'
|
||||||
|
conf['keep_idle'] = keepIdle_value
|
||||||
|
sock = wsgi.get_socket(conf)
|
||||||
|
# assert
|
||||||
|
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||||
|
expected_socket_opts[socket.IPPROTO_TCP][
|
||||||
|
socket.TCP_KEEPIDLE] = int(keepIdle_value)
|
||||||
|
self.assertEqual(sock.opts, expected_socket_opts)
|
||||||
|
|
||||||
|
# test keep_idle for negative value
|
||||||
|
conf['keep_idle'] = -600
|
||||||
|
self.assertRaises(wsgi.ConfigFileError, wsgi.get_socket, conf)
|
||||||
|
|
||||||
|
# test keep_idle for upperbound value
|
||||||
|
conf['keep_idle'] = 2 ** 15
|
||||||
|
self.assertRaises(wsgi.ConfigFileError, wsgi.get_socket, conf)
|
||||||
|
|
||||||
|
# test keep_idle for Type mismatch
|
||||||
|
conf['keep_idle'] = 'foobar'
|
||||||
|
self.assertRaises(wsgi.ConfigFileError, wsgi.get_socket, conf)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
wsgi.listen = old_listen
|
wsgi.listen = old_listen
|
||||||
wsgi.ssl = old_ssl
|
wsgi.ssl = old_ssl
|
||||||
|
Loading…
Reference in New Issue
Block a user