Eventlet green threads not released back to pool

Presently, the wsgi server allows persist connections hence even after the
response is sent to the client, it doesn't close the client socket connection.
Because of this problem, the green thread is not released back to the pool.

In order to close the client socket connection explicitly after the
response is sent and read successfully by the client, you simply have to
set keepalive to False when you create a wsgi server.

DocImpact:
Added wsgi_keep_alive option (default=True).
In order to maintain the backward compatibility, setting wsgi_keep_alive
as True by default. Recommended is set it to False.

This is port of Cinder change - [1]

[1] Ic57b2aceb136e8626388cfe4df72b2f47cb0661c

SecurityImpact
Closes-Bug: #1361360

Change-Id: If9241e6f6ba10592a64ca312cb479e8cea929913
This commit is contained in:
Valeriy Ponomaryov 2015-07-22 20:30:42 +03:00
parent 46538cd85c
commit accb273c7a
3 changed files with 9 additions and 0 deletions

View File

@ -261,6 +261,8 @@ function configure_manila {
iniset $MANILA_CONF oslo_concurrency lock_path $MANILA_LOCK_PATH
iniset $MANILA_CONF DEFAULT wsgi_keep_alive False
# Note: set up config group does not mean that this backend will be enabled.
# To enable it, specify its name explicitly using "enabled_share_backends" opt.
configure_default_backends

View File

@ -144,6 +144,7 @@ class TestWSGIServer(test.TestCase):
custom_pool=server._pool,
log=server._logger,
socket_timeout=server.client_socket_timeout,
keepalive=manila.wsgi.CONF.wsgi_keep_alive,
)
server.stop()

View File

@ -90,6 +90,11 @@ eventlet_opts = [
"If an incoming connection is idle for this number of "
"seconds it will be closed. A value of '0' means "
"wait forever."),
cfg.BoolOpt('wsgi_keep_alive',
default=True,
help='If False, closes the client socket connection '
'explicitly. Setting it to True to maintain backward '
'compatibility. Recommended setting is set it to False.'),
]
CONF = cfg.CONF
@ -238,6 +243,7 @@ class Server(service.ServiceBase):
'custom_pool': self._pool,
'log': self._logger,
'socket_timeout': self.client_socket_timeout,
'keepalive': CONF.wsgi_keep_alive,
}
self._server = eventlet.spawn(**wsgi_kwargs)