From: abhishekkekane Date: Fri, 12 Sep 2014 09:40:31 +0000 (-0700) Subject: Set socket options in correct way X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=47a26f1ac41100c40b7997bc4df802fa867fbd42;p=openstack-build%2Fcinder-build.git Set socket options in correct way Currently socket options, socket.SO_REUSEADDR and socket.SO_KEEPALIVE are set only if SSL is enabled. The above socket options should be set no matter SSL is enabled or not. Closes-Bug: #1369418 Change-Id: Ia5f6603918bda40be9965387bf464c581449d912 --- diff --git a/cinder/wsgi.py b/cinder/wsgi.py index efa04a9c0..cbd62e665 100644 --- a/cinder/wsgi.py +++ b/cinder/wsgi.py @@ -191,6 +191,18 @@ class Server(object): # to keep file descriptor usable. dup_socket = self._socket.dup() + dup_socket.setsockopt(socket.SOL_SOCKET, + socket.SO_REUSEADDR, 1) + + # NOTE(praneshp): Call set_tcp_keepalive in oslo to set + # tcp keepalive parameters. Sockets can hang around forever + # without keepalive + network_utils.set_tcp_keepalive(dup_socket, + CONF.tcp_keepalive, + CONF.tcp_keepidle, + CONF.tcp_keepalive_count, + CONF.tcp_keepalive_interval) + if self._use_ssl: try: ssl_kwargs = { @@ -206,17 +218,6 @@ class Server(object): dup_socket = ssl.wrap_socket(dup_socket, **ssl_kwargs) - - dup_socket.setsockopt(socket.SOL_SOCKET, - socket.SO_REUSEADDR, 1) - - # sockets can hang around forever without keepalive - network_utils.set_tcp_keepalive(dup_socket, - CONF.tcp_keepalive, - CONF.tcp_keepidle, - CONF.tcp_keepalive_count, - CONF.tcp_keepalive_interval) - except Exception: with excutils.save_and_reraise_exception(): LOG.error(_("Failed to start %(name)s on %(_host)s:"