main: Close the file descriptor we get from hook_connect().
We create a python socket object with fromfd() which duplicates the file descriptor we get from hook_connect(). Close the unneeded file descriptor instead of leaking it.
This commit is contained in:
parent
53b514809c
commit
fbf56d3491
1 changed files with 5 additions and 0 deletions
5
main.py
5
main.py
|
@ -17,6 +17,7 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import socket
|
||||
import ssl
|
||||
import textwrap
|
||||
|
@ -144,6 +145,10 @@ def wrap_socket(server, file_descriptor):
|
|||
temp_socket = socket.fromfd(file_descriptor, socket.AF_INET,
|
||||
socket.SOCK_STREAM)
|
||||
|
||||
# fromfd() duplicates the file descriptor, we can close the one we got from
|
||||
# weechat now since we use the one from our socket when calling hook_fd()
|
||||
os.close(file_descriptor)
|
||||
|
||||
# For python 2.7 wrap_socket() doesn't work with sockets created from an
|
||||
# file descriptor because fromfd() doesn't return a wrapped socket, the bug
|
||||
# was fixed for python 3, more info: https://bugs.python.org/issue13942
|
||||
|
|
Loading…
Reference in a new issue