Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unittest_mac_tsan_mbedtls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- uses: actions/checkout@v1
- uses: seanmiddleditch/gha-setup-ninja@master
- name: install mbedtls
run: brew install mbedtls
run: brew install mbedtls@3
- name: make test
run: make -f makefile.dev test_tsan_mbedtls
23 changes: 13 additions & 10 deletions ixwebsocket/IXSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,12 @@ namespace ix
}

// Accept a connection.
// FIXME: Is this working for ipv6 ?
struct sockaddr_in client; // client address information
int clientFd; // socket connected to client
socklen_t addressLen = sizeof(client);
memset(&client, 0, sizeof(client));
sockaddr_storage clientStorage; // client address information (v4 or v6)
int clientFd; // socket connected to client
socklen_t addressLen = sizeof(clientStorage);
memset(&clientStorage, 0, sizeof(clientStorage));

if ((clientFd = accept(_serverFd, (struct sockaddr*) &client, &addressLen)) < 0)
if ((clientFd = accept(_serverFd, (struct sockaddr*) &clientStorage, &addressLen)) < 0)
{
if (!Socket::isWaitNeeded())
{
Expand Down Expand Up @@ -346,8 +345,10 @@ namespace ix

if (_addressFamily == AF_INET)
{
auto* client = reinterpret_cast<sockaddr_in*>(&clientStorage);

char remoteIp4[INET_ADDRSTRLEN];
if (ix::inet_ntop(AF_INET, &client.sin_addr, remoteIp4, INET_ADDRSTRLEN) == nullptr)
if (ix::inet_ntop(AF_INET, &client->sin_addr, remoteIp4, INET_ADDRSTRLEN) == nullptr)
{
int err = Socket::getErrno();
std::stringstream ss;
Expand All @@ -360,13 +361,15 @@ namespace ix
continue;
}

remotePort = ix::network_to_host_short(client.sin_port);
remotePort = ix::network_to_host_short(client->sin_port);
remoteIp = remoteIp4;
}
else // AF_INET6
{
auto* client = reinterpret_cast<sockaddr_in6*>(&clientStorage);

char remoteIp6[INET6_ADDRSTRLEN];
if (ix::inet_ntop(AF_INET6, &client.sin_addr, remoteIp6, INET6_ADDRSTRLEN) ==
if (ix::inet_ntop(AF_INET6, &client->sin6_addr, remoteIp6, INET6_ADDRSTRLEN) ==
nullptr)
{
int err = Socket::getErrno();
Expand All @@ -380,7 +383,7 @@ namespace ix
continue;
}

remotePort = ix::network_to_host_short(client.sin_port);
remotePort = ix::network_to_host_short(client->sin6_port);
remoteIp = remoteIp6;
}

Expand Down
2 changes: 1 addition & 1 deletion makefile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ test_asan:
(cd build ; ctest -V .)

test_tsan_mbedtls:
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_MBED_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_MBED_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_PREFIX_PATH="$(shell brew --prefix mbedtls@3 2>/dev/null || echo /opt/homebrew/opt/mbedtls@3)")
(cd build ; ninja)
(cd build ; ninja test)

Expand Down
Loading