the_Foundation [main]

Socket: Potential thread safety issue

=> 4072d834bab61e0e28765db63206291399f3bb4e

diff --git a/src/platform/posix/socket.c b/src/platform/posix/socket.c
index 047ce16..2a0f9d2 100644
--- a/src/platform/posix/socket.c
+++ b/src/platform/posix/socket.c
@@ -365,6 +365,7 @@ static iThreadResult connectAsync_Socket_(iThread *thd) {
                 /* Ran out of addresses. */
                 break;
             }
+            lock_Mutex(&d->mutex);
             iDebug("[Socket] connecting async to %s (addrSize:%u index:%d)\n",
                    cstrCollect_String(toString_SockAddr(addr)),
                    addrSize, indexInFamily);
@@ -375,6 +376,7 @@ static iThreadResult connectAsync_Socket_(iThread *thd) {
             }
             iDebug("[Socket] family:%d type:%d protocol:%d\n", sp.family, sp.type, sp.protocol);
             d->fd = socket(sp.family, sp.type, sp.protocol);
+            unlock_Mutex(&d->mutex);
             if (!setNonBlocking_Socket_(d, iTrue)) {
                 /* Wait indefinitely. */
                 rc = connect(d->fd, addr, addrSize);
Proxy Information
Original URL
gemini://git.skyjake.fi/the_Foundation/main/cdiff/4072d834bab61e0e28765db63206291399f3bb4e
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
26.145043 milliseconds
Gemini-to-HTML Time
0.200809 milliseconds

This content has been proxied by September (3851b).