Question behavior about socket syscall in release 6.2
Martin Candurra
martincad at gmail.com
Mon Apr 28 03:00:48 UTC 2008
I have found some weird behavior about the socket system call in freebsd
release 6.2.
The problem appears if I try to open more sockets than the ulimits allows:
the socket system call gets blocked instead of returning an EMFILE error.
This only happens to me in release 6.2 ( I tested in 7.0 but it works fine).
The following python script is what I have used to reproduce the issue:
import os
import socket
from random import randint
import sys
socketAddress = ("127.0.0.1", randint(20000, 30000))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(socketAddress)
s.listen(1)
socketList = []
child = -1
for i in range(10000):
child = os.fork()
if (child):
clientCon, address = s.accept()
socketList.append(clientCon)
os.waitpid(0, os.WNOHANG)
else:
print "child %d" % i
clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if (clientSocket==-1):
print("client socket error")
err = clientSocket.connect(socketAddress)
if (err==-1):
print("client connect error")
break
Is there something I'm missing ? Can someone shed me some light about this ?
Thanks in advance.
Best regards.
More information about the freebsd-questions
mailing list