[Twisted-Python] Problem with SYN_SENT's under SCO

Richard Sharp Richard.Sharp at t-online.de
Mon Aug 9 07:16:46 MDT 2004


Hello,
I recently had a problem under SCO that I had to solve. The program was 
piling up open socket objects all hanging in the state of SYN_SENT. 
Eventually the maximum number of open files was exceeded and the 
application hung badly.

I eventually narrowed the problem down with a perfectly normal python 
program to trying to connect as a client to a server that is not 
listening. The first connect returns the error EINPROGRESS, the second 
connect then returns the error "Connection refused". Running a simple 
program that repeatedly tried to connect, I could use "netstat -a" to 
watch the SYN_SENT's increasing. This only appears to happen under SCO 
and even here I am not sure whether it is not version specific.

I discovered that closing the socket object after the "connection 
refused" seemed to release any open objects and removed the SYN_SENTS, 
so I changed failIfNotConnected to what you see below. There may be a 
better or more appropriate solution but this has at least got rid of my 
problem.

Version 1.3.0 internet/tcp.py from line 355:

def failIfNotConnected(self, err):
        if sys.platform[0:3] != 'sco':
            if (self.connected or
                self.disconnected or
                not (hasattr(self, "connector"))):
                return
        else:
            self.socket.close()
            if not (hasattr(self,"connector")):
                return
        self.connector.connectionFailed(failure.Failure(err))
        if hasattr(self, "reactor"):
            # this doesn't happens if we failed in __init__
            self.stopReading()
            self.stopWriting()
            del self.connector

greetings,

Richard Sharp





More information about the Twisted-Python mailing list