VirtualBox

Changeset 71988 in vbox for trunk/src


Ignore:
Timestamp:
Apr 23, 2018 8:08:37 PM (7 years ago)
Author:
vboxsync
Message:

ValidationKit/serial: Properly shutodwn the listening socket to avoid address in use errors for consecutive tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/serial/loopback.py

    r70797 r71988  
    4949        self.oSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
    5050        self.oSock.settimeout(iTimeout);
     51        self.oSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1);
    5152        self.oSock.bind((sHost, int(sPort)));
    5253        self.oSock.listen(1);
     
    5657        if self.oConn is not None:
    5758            self.oConn.close();
     59        if self.oSock is not None:
     60            self.oSock.close();
     61            self.oSock = None;
     62
     63    def shutdown(self):
     64        if self.oConn is not None:
     65            self.oConn.close();
     66            self.oConn = None;
    5867        self.oSock.close();
     68        self.oSock = None;
    5969
    6070    def pumpIo(self):
     
    8595
    8696    def __del__(self):
    87         self.oConn.close();
     97        if self.oConn is not None:
     98            self.oConn.close();
     99
     100    def shutdown(self):
     101        if self.oConn is not None:
     102            self.oConn.close();
     103            self.oConn = None;
    88104
    89105    def pumpIo(self):
     
    113129        if self.oConn is not None:
    114130            self.oConn.close();
     131        if self.oSock is not None:
     132            self.oSock.close();
     133            self.oSock = None;
     134
     135    def shutdown(self):
     136        if self.oConn is not None:
     137            self.oConn.close();
     138            self.oConn = None;
    115139        self.oSock.close();
     140        self.oSock = None;
    116141
    117142    def pumpIo(self):
     
    141166
    142167    def __del__(self):
    143         self.oConn.close();
     168        if self.oConn is not None:
     169            self.oConn.close();
     170
     171    def shutdown(self):
     172        if self.oConn is not None:
     173            self.oConn.close();
     174            self.oConn = None;
    144175
    145176    def pumpIo(self):
     
    196227        self.fShutdown = True;
    197228        self.oLock.release();
     229        self.oIoPumper.shutdown();
    198230
    199231    def isShutdown(self):
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette