WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Cleanup timeout code for when socket is already in use.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Cleanup timeout code for when socket is already in use.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Sep 2005 09:00:11 +0000
Delivery-date: Thu, 15 Sep 2005 08:58:42 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 7ce64f021a2c6bb092d8c940dadfa17ad18ac56f
# Parent  6da7a6d8b575f999315bd81c7acd9f9c9538c9d1
Cleanup timeout code for when socket is already in use.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 6da7a6d8b575 -r 7ce64f021a2c tools/python/xen/web/tcp.py
--- a/tools/python/xen/web/tcp.py       Thu Sep 15 08:56:13 2005
+++ b/tools/python/xen/web/tcp.py       Thu Sep 15 08:59:35 2005
@@ -19,6 +19,7 @@
 import socket
 import types
 import time
+import errno
 
 from connection import *
 from protocol import *
@@ -40,22 +41,16 @@
         # SO_REUSEADDR does not always ensure that we do not get an address
         # in use error when restarted quickly
         # we implement a timeout to try and avoid failing unnecessarily
-
         timeout = time.time() + 30
-        again = True
-        while again and time.time() < timeout:
-            again = False
+        while True:
             try:
                 sock.bind((self.interface, self.port))
-            except socket.error, (errno, strerrno):
-                if errno == 98:
-                    again = True
+                return sock
+            except socket.error, (_errno, strerrno):
+                if _errno == errno.EADDRINUSE and time.time() < timeout:
+                    time.sleep(0.5)
                 else:
-                    raise socket.error(errno, strerrno)
-        if again:
-            raise socket.error(98, "address in use")
-                
-        return sock
+                    raise
 
     def acceptConnection(self, sock, protocol, addr):
         return TCPServerConnection(sock, protocol, addr, self)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Cleanup timeout code for when socket is already in use., Xen patchbot -unstable <=