]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Set socket options in correct way
authorabhishekkekane <abhishek.kekane@nttdata.com>
Fri, 12 Sep 2014 09:40:31 +0000 (02:40 -0700)
committerabhishekkekane <abhishek.kekane@nttdata.com>
Thu, 18 Sep 2014 13:06:12 +0000 (06:06 -0700)
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

cinder/wsgi.py

index efa04a9c00f0f2244ebf4618df31628fae49741f..cbd62e665554e74250149e0edee3485160858e03 100644 (file)
@@ -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:"