Date: Sun, 27 Apr 2008 23:34:28 -0300 From: "Martin Candurra" <martincad@gmail.com> To: freebsd-questions@freebsd.org Subject: Question behavior about socket syscall in release 6.2 Message-ID: <2062979c0804271934v4208686dq5f02d9c2c21bde84@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2062979c0804271934v4208686dq5f02d9c2c21bde84>
