[Pymilter] poll() returned exception for socket, abort

Tom Hendrikx tom at whyscream.net
Sun Jan 13 07:09:17 EST 2013


Hi,

I'm currently adding daemon support to my milter, using a simplified
version of the routine as documented in PEP3143 and implemented in
http://pypi.python.org/pypi/python-daemon/

For some reason, the milter aborts after processing the single
connection. The first connection is handled properly, and a few seconds
after the disconnect is completed, syslog reports: "python: MyMilter:
poll() returned exception for socket, abort", and the milter process is
gone.

I narrowed it down to closing all file descriptors. When using this
piece of code:

    # Close file descriptors
    save_fds = [sys.stderr.fileno()]
    for fd in reversed(range(2048)):
        if fd not in save_fds:
            try:
                os.close(fd)
                print('Closed fd {}'.format(fd))
            except OSError, err:
                if err.errno == errno.EBADF:
                    # File descriptor was not open
                    pass

This works, as long as there is at least one fd listed in save_fds. It
doesn't matter whether it's stdout, stderr or stdin: anyone will do. As
soon as I set 'safe_fds = [], and all fds are closed, the above error
turns up and the milter exits after the first connection.

Any ideas? I can't even find where this error message is generated...

--
Tom



More information about the Pymilter mailing list