Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock full after receiving connection from few clients #5

Open
mdczaplicki opened this issue Sep 14, 2018 · 1 comment
Open

Lock full after receiving connection from few clients #5

mdczaplicki opened this issue Sep 14, 2018 · 1 comment
Assignees

Comments

@mdczaplicki
Copy link

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()
@kaleb-himes
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants