Skip to content

NetfilterQueue() create socket fd and never release #84

@1ncande5cence

Description

@1ncande5cence

Hi! Here is my code.

self.out_nfqueue = netfilterqueue.NetfilterQueue()
self.out_nfqueue.bind(self.out_queue_num,self.out_callback)
self.out_nfqueue_socket = socket.fromfd(self.out_nfqueue.get_fd(),socket.AF_UNIX,socket.SOCK_STREAM)
... 
# when I finish
self.out_nfqueue.unbind()
self.out_nfqueue_socket.close()

In line 1, Class NetfilterQueue will create a FileDescriptor in /proc/fd/ . But when I finish these code. this socket will not be released and still in /proc/fd/ . However the FileDescriptor created in line 3 will be released in line 7 nicely.
I need to call the above code many times. I discovered that the FileDescriptor created in line 1 can not be released correctly, which lead to crashes of opening too many filedescriptors ( filedescriptor out of range in select() ).

So how should I solve this problem? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions