Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
aff8275
Update spdlog to v1.17.0 to get rid of deprecation warnings when comp…
cosminpolifronie Apr 25, 2026
b6ffa1d
Use latest master commit of msgpack11 to fix MacOS build warnings and…
cosminpolifronie Apr 25, 2026
3d7d80e
Fix unused variable preferTLS warning in MacOS
cosminpolifronie Apr 25, 2026
d314532
Remove CLI11 and cpp-linenoise from third_party directory and fetch n…
cosminpolifronie Apr 25, 2026
912d856
Fix build warnings on Windows with clang 21
cosminpolifronie Apr 25, 2026
8240286
Fix build warnings when building without zlib
cosminpolifronie Apr 25, 2026
7a82110
Merge remote-tracking branch 'machinezone/master' into fix-macos-buil…
cosminpolifronie Apr 28, 2026
5d53240
Remove reference to previously removed third_party whitespace script
cosminpolifronie Apr 28, 2026
5ccf841
Merge remote-tracking branch 'machinezone/master' into fix-macos-buil…
cosminpolifronie May 2, 2026
d6b7ada
Update msgpack11 to latest commit
cosminpolifronie Jun 25, 2026
fab3cdb
Merge branch 'master' into fix-macos-build-warnings
cosminpolifronie Jun 25, 2026
332f6e0
Update cpp_linenoise to latest version
cosminpolifronie Jun 25, 2026
ec1cbd5
Fix compilation warnings and errors in IXSocketMbedTLS.cpp
cosminpolifronie Jun 25, 2026
e6b1539
Remove embedded Catch2 and use external repository with tag v3.15.1
cosminpolifronie Jun 25, 2026
b0e4bda
Fix build warnings in IXSocketOpenSSL.cpp
cosminpolifronie Jun 25, 2026
249c318
Update GitHub Actions unittest_mac_tsan_openssl to openssl 3.5
cosminpolifronie Jun 25, 2026
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_openssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
- uses: actions/checkout@v1
- uses: seanmiddleditch/gha-setup-ninja@master
- name: install openssl
run: brew install openssl@1.1
run: brew install openssl@3.5
- name: make test
run: make -f makefile.dev test_tsan_openssl
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,33 @@ endif()

if (USE_WS OR USE_TEST)
include(FetchContent)

set(MSGPACK11_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE)

FetchContent_Declare(msgpack11
GIT_REPOSITORY "https://github.com/ar90n/msgpack11"
GIT_TAG "892264112b52b75b37cb1f83c41abfb5aff765af"
GIT_SHALLOW 1)

FetchContent_Declare(spdlog
GIT_REPOSITORY "https://github.com/gabime/spdlog"
GIT_TAG "v1.17.0"
GIT_SHALLOW 1)

FetchContent_MakeAvailable(spdlog)
FetchContent_MakeAvailable(spdlog msgpack11)

if (USE_WS)
add_subdirectory(ws)
endif()
if (USE_TEST)
FetchContent_Declare(Catch2
GIT_REPOSITORY "https://github.com/catchorg/Catch2"
GIT_TAG "v3.15.1"
GIT_SHALLOW 1)

FetchContent_MakeAvailable(Catch2)

enable_testing()
add_subdirectory(test)
endif()
Expand Down
3 changes: 3 additions & 0 deletions ixwebsocket/IXGzipCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace ix
std::string gzipCompress(const std::string& str)
{
#ifndef IXWEBSOCKET_USE_ZLIB
(void) str;
return std::string();
#else
z_stream zs; // z_stream is zlib's control structure
Expand Down Expand Up @@ -74,6 +75,8 @@ namespace ix
bool gzipDecompress(const std::string& in, std::string& out)
{
#ifndef IXWEBSOCKET_USE_ZLIB
(void) in;
(void) out;
return false;
#else
z_stream inflateState;
Expand Down
4 changes: 2 additions & 2 deletions ixwebsocket/IXNetSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace ix
}
}

DWORD n = WSAWaitForMultipleEvents(handles.size(), handles.data(), FALSE, timeout != -1 ? static_cast<DWORD>(timeout) : WSA_INFINITE, FALSE);
DWORD n = WSAWaitForMultipleEvents(static_cast<DWORD>(handles.size()), handles.data(), FALSE, timeout != -1 ? static_cast<DWORD>(timeout) : WSA_INFINITE, FALSE);

if (n == WSA_WAIT_FAILED) return SOCKET_ERROR;
if (n == WSA_WAIT_TIMEOUT) return 0;
Expand Down Expand Up @@ -243,7 +243,7 @@ namespace ix
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;

int ret = select(maxfd + 1, &readfds, &writefds, &errorfds, timeout != -1 ? &tv : NULL);
int ret = select(static_cast<int>(maxfd + 1), &readfds, &writefds, &errorfds, timeout != -1 ? &tv : NULL);

if (ret < 0)
{
Expand Down
4 changes: 4 additions & 0 deletions ixwebsocket/IXNetSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#define WIN32_LEAN_AND_MEAN
#endif

#ifndef NOMINMAX
#define NOMINMAX
#endif

#include <ws2tcpip.h>
#include <winsock2.h>
#include <basetsd.h>
Expand Down
12 changes: 10 additions & 2 deletions ixwebsocket/IXSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace ix

PollResultType Socket::poll(bool readyToRead,
int timeoutMs,
int sockfd,
socket_t sockfd,
const SelectInterruptPtr& selectInterrupt)
{
PollResultType pollResult = PollResultType::ReadyForRead;
Expand Down Expand Up @@ -247,7 +247,11 @@ namespace ix
flags = MSG_NOSIGNAL;
#endif

#ifdef _WIN32
return ::send(_sockfd, buffer, static_cast<int>(length), flags);
#else
return ::send(_sockfd, buffer, length, flags);
#endif
}

ssize_t Socket::send(const std::string& buffer)
Expand All @@ -262,7 +266,11 @@ namespace ix
flags = MSG_NOSIGNAL;
#endif

#ifdef _WIN32
return ::recv(_sockfd, (char*) buffer, static_cast<int>(length), flags);
#else
return ::recv(_sockfd, (char*) buffer, length, flags);
#endif
}

int Socket::getErrno()
Expand Down Expand Up @@ -290,7 +298,7 @@ namespace ix
return false;
}

void Socket::closeSocket(int fd)
void Socket::closeSocket(socket_t fd)
{
#ifdef _WIN32
closesocket(fd);
Expand Down
5 changes: 3 additions & 2 deletions ixwebsocket/IXSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef SSIZE_T ssize_t;
#endif

#include "IXCancellationRequest.h"
#include "IXNetSystem.h"
#include "IXProgressCallback.h"
#include "IXSelectInterrupt.h"

Expand Down Expand Up @@ -81,11 +82,11 @@ namespace ix

static int getErrno();
static bool isWaitNeeded();
static void closeSocket(int fd);
static void closeSocket(socket_t fd);

static PollResultType poll(bool readyToRead,
int timeoutMs,
int sockfd,
socket_t sockfd,
const SelectInterruptPtr& selectInterrupt);

protected:
Expand Down
6 changes: 3 additions & 3 deletions ixwebsocket/IXSocketConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ix
// block us for too long
SocketConnect::configure(fd);

int res = ::connect(fd, address->ai_addr, address->ai_addrlen);
int res = ::connect(fd, address->ai_addr, static_cast<int>(address->ai_addrlen));

if (res == -1 && !Socket::isWaitNeeded())
{
Expand Down Expand Up @@ -80,7 +80,7 @@ namespace ix
}
else if (pollResult == PollResultType::ReadyForWrite)
{
return fd;
return static_cast<int>(fd);
}
else
{
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace ix
}

// FIXME: configure is a terrible name
void SocketConnect::configure(int sockfd)
void SocketConnect::configure(socket_t sockfd)
{
// 1. disable Nagle's algorithm
int flag = 1;
Expand Down
3 changes: 2 additions & 1 deletion ixwebsocket/IXSocketConnect.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include "IXCancellationRequest.h"
#include "IXNetSystem.h"
#include <string>

struct addrinfo;
Expand All @@ -21,7 +22,7 @@ namespace ix
std::string& errMsg,
const CancellationRequest& isCancellationRequested);

static void configure(int sockfd);
static void configure(socket_t sockfd);

private:
static int connectToAddress(const struct addrinfo* address,
Expand Down
4 changes: 2 additions & 2 deletions ixwebsocket/IXSocketMbedTLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ namespace ix

return true;
#else
(void)errorMsg;
// On macOS we can query the system cert location from the keychain
// On Linux we could try to fetch some local files based on the distribution
// On Android we could use JNI to get to the system certs
Expand All @@ -110,9 +111,8 @@ namespace ix
initMBedTLS();
std::lock_guard<std::mutex> lock(_mutex);

const char* pers = "IXSocketMbedTLS";

#if MBEDTLS_VERSION_MAJOR < 4
const char* pers = "IXSocketMbedTLS";
if (mbedtls_ctr_drbg_seed(&_ctr_drbg,
mbedtls_entropy_func,
&_entropy,
Expand Down
2 changes: 2 additions & 0 deletions ixwebsocket/IXSocketOpenSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ namespace ix
bool SocketOpenSSL::checkHost(const std::string& host, const char* pattern)
{
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
(void)host;
(void)pattern;
return true;
#else

Expand Down
2 changes: 1 addition & 1 deletion ixwebsocket/IXSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ namespace ix
socklen_t addressLen = sizeof(client);
memset(&client, 0, sizeof(client));

if ((clientFd = accept(_serverFd, (struct sockaddr*) &client, &addressLen)) < 0)
if ((clientFd = static_cast<int>(accept(_serverFd, (struct sockaddr*) &client, &addressLen))) < 0)
{
if (!Socket::isWaitNeeded())
{
Expand Down
8 changes: 4 additions & 4 deletions ixwebsocket/IXUdpSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace ix
return false;
}

void UdpSocket::closeSocket(int fd)
void UdpSocket::closeSocket(socket_t fd)
{
#ifdef _WIN32
closesocket(fd);
Expand All @@ -67,7 +67,7 @@ namespace ix

bool UdpSocket::init(const std::string& host, int port, std::string& errMsg)
{
_sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
_sockfd = static_cast<int>(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP));
if (_sockfd < 0)
{
errMsg = "Could not create socket";
Expand Down Expand Up @@ -110,7 +110,7 @@ namespace ix
ssize_t UdpSocket::sendto(const std::string& buffer)
{
return (ssize_t)::sendto(
_sockfd, buffer.data(), buffer.size(), 0, (struct sockaddr*) &_server, sizeof(_server));
_sockfd, buffer.data(), static_cast<int>(buffer.size()), 0, (struct sockaddr*) &_server, sizeof(_server));
}

ssize_t UdpSocket::recvfrom(char* buffer, size_t length)
Expand All @@ -121,6 +121,6 @@ namespace ix
socklen_t addressLen = (socklen_t) sizeof(_server);
#endif
return (ssize_t)::recvfrom(
_sockfd, buffer, length, 0, (struct sockaddr*) &_server, &addressLen);
_sockfd, buffer, static_cast<int>(length), 0, (struct sockaddr*) &_server, &addressLen);
}
} // namespace ix
2 changes: 1 addition & 1 deletion ixwebsocket/IXUdpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ix

static int getErrno();
static bool isWaitNeeded();
static void closeSocket(int fd);
static void closeSocket(socket_t fd);

private:
std::atomic<int> _sockfd;
Expand Down
8 changes: 8 additions & 0 deletions ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace ix

return true;
#else
(void) deflateBits;
(void) clientNoContextTakeOver;
return false;
#endif
}
Expand Down Expand Up @@ -163,6 +165,8 @@ namespace ix

return true;
#else
(void) in;
(void) out;
return false;
#endif
}
Expand Down Expand Up @@ -202,6 +206,8 @@ namespace ix

return true;
#else
(void) inflateBits;
(void) clientNoContextTakeOver;
return false;
#endif
}
Expand Down Expand Up @@ -246,6 +252,8 @@ namespace ix

return true;
#else
(void) in;
(void) out;
return false;
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions ixwebsocket/IXWebSocketPerMessageDeflateCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace ix
template<typename T>
bool endsWithEmptyUnCompressedBlock(const T& value);

#ifdef IXWEBSOCKET_USE_ZLIB
int _flush;
std::array<unsigned char, 1 << 14> _compressBuffer;

#ifdef IXWEBSOCKET_USE_ZLIB
z_stream _deflateState;
#endif
};
Expand All @@ -54,10 +54,10 @@ namespace ix
bool decompress(const std::string& in, std::string& out);

private:
#ifdef IXWEBSOCKET_USE_ZLIB
int _flush;
std::array<unsigned char, 1 << 14> _compressBuffer;

#ifdef IXWEBSOCKET_USE_ZLIB
z_stream _inflateState;
#endif
};
Expand Down
5 changes: 3 additions & 2 deletions ixwebsocket/IXWebSocketPerMessageDeflateOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ namespace ix
{
/// Default values as defined in the RFC
const uint8_t WebSocketPerMessageDeflateOptions::kDefaultServerMaxWindowBits = 15;
const uint8_t WebSocketPerMessageDeflateOptions::kDefaultClientMaxWindowBits = 15;
#ifdef IXWEBSOCKET_USE_ZLIB
static const uint8_t minServerMaxWindowBits = 8;
static const uint8_t maxServerMaxWindowBits = 15;

const uint8_t WebSocketPerMessageDeflateOptions::kDefaultClientMaxWindowBits = 15;
static const uint8_t minClientMaxWindowBits = 8;
static const uint8_t maxClientMaxWindowBits = 15;
#endif

WebSocketPerMessageDeflateOptions::WebSocketPerMessageDeflateOptions(
bool enabled,
Expand Down
4 changes: 0 additions & 4 deletions makefile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ deploy: docker docker_push
run:
docker run --cap-add sys_ptrace --entrypoint=sh -it bsergean/ws:build

# this is helpful to remove trailing whitespaces
trail:
sh third_party/remote_trailing_whitespaces.sh

format:
clang-format -i `find test ixwebsocket ws -name '*.cpp' -o -name '*.h'`

Expand Down
Loading
Loading