Lock full after receiving connection from few clients
I am receiving this error from wolfssl python library.
Am using python 3.6 and this is what I get in console after like 5 clients connect to my socket:
wolfSSL Leaving SendTls13EncryptedExtensions, return -308
wolfSSL error occurred, error = 308 line:7618 file:src/tls13.c
wolfSSL Leaving wolfSSL_negotiate, return -1
wolfSSL Entering SSL_CTX_free
python: ../nptl/pthread_mutex_lock.c:425: __pthread_mutex_lock_full: Assertion `INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH || !robust' failed.
Is there anything you could help with this? If you need more info, let me know I will anwser.
That's the part of code I am using:
def __init__(self, host, port):
self.host = host
self.port = port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.setblocking(True)
self.sock.bind((self.host, self.port))
self.lock = threading.Lock()
def listen(self):
self.sock.listen(10)
print('Server listening on port', self.sock.getsockname()[1])
context = wolfssl.SSLContext(wolfssl.PROTOCOL_TLSv1_3, server_side=True)
context.load_cert_chain(CERTIFICATE, KEY)
context.verify_mode = wolfssl.CERT_REQUIRED
context.load_verify_locations(CERTIFICATE)
try:
while True:
new_socket, from_address = self.sock.accept()
print('Connection address:', from_address)
new_socket.settimeout(60)
new_socket.setblocking(True)
secure_socket = context.wrap_socket(new_socket)
threading.Thread(target=self.listen_to_client, args=(secure_socket, from_address)).start()
finally:
self.sock.close()
In brief, the problem is caused by repeated locking of a fast mutex, and solved by using a recursive mutex. The default pthread_mutex_t is not recursive. Were you able to resolve this locally? If so, we would welcome a patch via a pull request on the wolfSSL Python solution. If you do decide to open a PR just shoot us an email at [email protected] and we will send over a contributor agreement for review and signing.
Warm Regards,
- K