Skip to content
Merged
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
3 changes: 1 addition & 2 deletions Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_WinsockTcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

struct SolidSyslogResolver;

static SolidSyslogWinsockTcpStreamStorage underlyingStreamStorage;
static struct SolidSyslogStream* underlyingStream;
static SolidSyslogTlsStreamStorage tlsStreamStorage;
static struct SolidSyslogStream* tlsStream;
static struct SolidSyslogSender* sender;

struct SolidSyslogSender* BddTargetTlsSender_Create(struct SolidSyslogResolver* resolver, bool mtls)
{
underlyingStream = SolidSyslogWinsockTcpStream_Create(&underlyingStreamStorage);
underlyingStream = SolidSyslogWinsockTcpStream_Create();

static struct SolidSyslogTlsStreamConfig tlsStreamConfig;
tlsStreamConfig = (struct SolidSyslogTlsStreamConfig) {0};
Expand Down
16 changes: 7 additions & 9 deletions Bdd/Targets/Windows/BddTargetWindows.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ enum
static const char* const STORE_PATH_PREFIX = "Bdd/output/STORE";
static const char* const THRESHOLD_MARKER_PATH = "Bdd/output/solidsyslog_threshold_marker.log";

static SolidSyslogWinsockTcpStreamStorage tcpStreamStorage;
static uint8_t bufferRing[SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES(BDD_TARGET_BUFFER_MESSAGES)];
static SolidSyslogWindowsMutexStorage mutexStorage;
static SolidSyslogWindowsAtomicCounterStorage counterStorage;
static volatile bool shutdownFlag;

/* Created in CreateSender, destroyed in DestroySender — held in file scope so
teardown can reach them after the SwitchingSender wraps them all. */
static struct SolidSyslogResolver* resolver;
static struct SolidSyslogStream* plainTcpStream;
static struct SolidSyslogSender* plainTcpSender;
static struct SolidSyslogDatagram* udpDatagram;
Expand Down Expand Up @@ -179,7 +178,7 @@ static struct SolidSyslogSender* CreateSender(const struct BddTargetWindowsOptio
{
bool mtlsModeActive = (strcmp(options->Transport, "mtls") == 0);

struct SolidSyslogResolver* resolver = SolidSyslogWinsockResolver_Create();
resolver = SolidSyslogWinsockResolver_Create();

udpDatagram = SolidSyslogWinsockDatagram_Create();
static struct SolidSyslogUdpSenderConfig udpConfig = {0};
Expand All @@ -189,7 +188,7 @@ static struct SolidSyslogSender* CreateSender(const struct BddTargetWindowsOptio
udpConfig.EndpointVersion = GetEndpointVersion;
udpSender = SolidSyslogUdpSender_Create(&udpConfig);

plainTcpStream = SolidSyslogWinsockTcpStream_Create(&tcpStreamStorage);
plainTcpStream = SolidSyslogWinsockTcpStream_Create();
static struct SolidSyslogStreamSenderConfig tcpConfig = {0};
tcpConfig.Resolver = resolver;
tcpConfig.Stream = plainTcpStream;
Expand Down Expand Up @@ -221,8 +220,8 @@ static void DestroySender(void)
SolidSyslogStreamSender_Destroy(plainTcpSender);
SolidSyslogWinsockTcpStream_Destroy(plainTcpStream);
SolidSyslogUdpSender_Destroy(udpSender);
SolidSyslogWinsockDatagram_Destroy();
SolidSyslogWinsockResolver_Destroy();
SolidSyslogWinsockDatagram_Destroy(udpDatagram);
SolidSyslogWinsockResolver_Destroy(resolver);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

static struct SolidSyslogStore* CreateStore(const struct BddTargetWindowsOptions* options)
Expand All @@ -231,8 +230,7 @@ static struct SolidSyslogStore* CreateStore(const struct BddTargetWindowsOptions

if (useFile)
{
static SolidSyslogWindowsFileStorage fileStorage;
storeFile = SolidSyslogWindowsFile_Create(&fileStorage);
storeFile = SolidSyslogWindowsFile_Create();

storeBlockDevice = SolidSyslogFileBlockDevice_Create(storeFile, STORE_PATH_PREFIX);

Expand Down Expand Up @@ -299,7 +297,7 @@ int BddTargetWindows_Run(int argc, char* argv[])
struct SolidSyslogSender* sender = CreateSender(&options);
struct SolidSyslogStore* store = CreateStore(&options);

struct SolidSyslogMutex* mutex = SolidSyslogWindowsMutex_Create(&mutexStorage);
struct SolidSyslogMutex* mutex = SolidSyslogWindowsMutex_Create();
struct SolidSyslogBuffer* buffer = SolidSyslogCircularBuffer_Create(mutex, bufferRing, sizeof(bufferRing));
struct SolidSyslogAtomicCounter* counter = SolidSyslogWindowsAtomicCounter_Create(&counterStorage);
struct SolidSyslogMetaSdConfig metaConfig = {
Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ live under `Core/Interface/`; platform-specific helpers (the `SolidSyslogPosix*`
| `SolidSyslogMutexDefinition.h` | Mutex implementors (extension point) | `SolidSyslogMutex` vtable struct (`Lock`, `Unlock`) |
| `SolidSyslogNullMutex.h` | System setup code (single-task, no synchronisation) | `SolidSyslogNullMutex_Get` |
| `SolidSyslogPosixMutex.h` | System setup code on POSIX targets needing thread-safe buffering | `SolidSyslogPosixMutex_Create(void)`, `_Destroy(base)` (wraps `pthread_mutex_t`). Instance struct lives in a library-internal static pool (E11). Pool-exhaustion fallback is the shared `SolidSyslogNullMutex`. |
| `SolidSyslogWindowsMutex.h` | System setup code on Windows targets needing thread-safe buffering | `SolidSyslogWindowsMutexStorage`, `SOLIDSYSLOG_WINDOWSMUTEX_SIZE`, `SolidSyslogWindowsMutex_Create(storage)`, `_Destroy(mutex)` (wraps `CRITICAL_SECTION`) |
| `SolidSyslogWindowsMutex.h` | System setup code on Windows targets needing thread-safe buffering | `SolidSyslogWindowsMutex_Create(void)`, `_Destroy(base)` (wraps `CRITICAL_SECTION`). Instance struct lives in a library-internal static pool (E11). Pool-exhaustion fallback is the shared `SolidSyslogNullMutex`. |
| `SolidSyslogFreeRtosMutex.h` | System setup code on FreeRTOS targets needing thread-safe buffering | `SolidSyslogFreeRtosMutexStorage`, `SOLIDSYSLOG_FREERTOSMUTEX_SIZE`, `SolidSyslogFreeRtosMutex_Create(storage)`, `_Destroy(mutex)` (wraps `xSemaphoreCreateMutexStatic` — caller's `StaticSemaphore_t` lives inside the injected storage; requires `configSUPPORT_STATIC_ALLOCATION=1`) |
| `SolidSyslogStore.h` | Library internals consuming a store (Service algorithm) and integrator code querying capacity | `SolidSyslogStore_Write`, `_ReadNextUnsent`, `_MarkSent`, `_HasUnsent`, `_IsHalted`, `_GetTotalBytes`, `_GetUsedBytes` |
| `SolidSyslogStoreDefinition.h` | Store implementors (extension point) | `SolidSyslogStore` vtable struct (`Write`, `ReadNextUnsent`, `MarkSent`, `HasUnsent`, `IsHalted`, `GetTotalBytes`, `GetUsedBytes`) |
Expand All @@ -367,7 +367,7 @@ live under `Core/Interface/`; platform-specific helpers (the `SolidSyslogPosix*`
| `SolidSyslogCrc16Policy.h` | System setup code using CRC-16 integrity | `SolidSyslogCrc16Policy_Create`, `_Destroy` |
| `SolidSyslogCrc16.h` | Any code needing CRC-16 computation | `SolidSyslogCrc16_Compute` |
| `SolidSyslogPosixFile.h` | System setup code using POSIX file I/O | `SolidSyslogPosixFile_Create(void)`, `_Destroy(base)`. Instance struct lives in a library-internal static pool (E11). Pool-exhaustion fallback is the shared `SolidSyslogNullFile`. |
| `SolidSyslogWindowsFile.h` | System setup code using Windows file I/O (MSVC `<io.h>`) | `SolidSyslogWindowsFile_Create`, `_Destroy` |
| `SolidSyslogWindowsFile.h` | System setup code using Windows file I/O (MSVC `<io.h>`) | `SolidSyslogWindowsFile_Create(void)`, `_Destroy(base)`. Instance struct lives in a library-internal static pool (E11). Pool-exhaustion fallback is the shared `SolidSyslogNullFile`. |
| `SolidSyslogFatFsFile.h` | System setup code on targets using ChaN FatFs as the file layer (bare-metal flash / SD / eMMC, FreeRTOS, Zephyr, NuttX, …) | `SolidSyslogFatFsFileStorage`, `SOLIDSYSLOG_FATFS_FILE_SIZE`, `SolidSyslogFatFsFile_Create(storage)`, `_Destroy(file)` (wraps `f_open` / `f_close` / `f_read` / `f_write` with `f_sync` after every successful write so a power loss never loses a record the BlockStore claimed it stored; integrator supplies `diskio.c` and — if `FF_FS_REENTRANT=1` — `ffsystem.c`) |
| `SolidSyslogPosixClock.h` | System setup code using POSIX clock | `SolidSyslogPosixClock_GetTimestamp` |
| `SolidSyslogPosixHostname.h` | String callback implementor using POSIX hostname | `SolidSyslogPosixHostname_Get` (writes into `SolidSyslogFormatter*`) |
Expand Down
98 changes: 98 additions & 0 deletions Core/Interface/SolidSyslogTunablesDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,102 @@
#error "SOLIDSYSLOG_ORIGIN_SD_POOL_SIZE must be >= 1"
#endif

/*
* Number of SolidSyslogWindowsMutex instances the library's internal
* static pool can simultaneously hold. Each instance carries a
* CRITICAL_SECTION.
*
* Default 1 — almost all integrators wire a single WindowsMutex into
* a CircularBuffer or other thread-safe primitive. Bump via
* SOLIDSYSLOG_USER_TUNABLES_FILE if more than one is genuinely
* needed.
*
* Floor: 1. Sub-floor values rejected at compile time.
*/
#ifndef SOLIDSYSLOG_WINDOWS_MUTEX_POOL_SIZE
/* NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -- macro form required for preprocessor visibility (floor #if) and C array-size const-expr. */
#define SOLIDSYSLOG_WINDOWS_MUTEX_POOL_SIZE 1U
#endif

#if SOLIDSYSLOG_WINDOWS_MUTEX_POOL_SIZE < 1
#error "SOLIDSYSLOG_WINDOWS_MUTEX_POOL_SIZE must be >= 1"
#endif

/*
* Number of SolidSyslogWinsockDatagram instances the library's internal
* static pool can simultaneously hold. Each instance carries the AF_INET
* SOCKET handle and a one-shot connect flag.
*
* Default 1 — almost all integrators wire a single WinsockDatagram into
* a UdpSender. Bump via SOLIDSYSLOG_USER_TUNABLES_FILE if more than one
* is genuinely needed.
*
* Floor: 1. Sub-floor values rejected at compile time.
*/
#ifndef SOLIDSYSLOG_WINSOCK_DATAGRAM_POOL_SIZE
/* NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -- macro form required for preprocessor visibility (floor #if) and C array-size const-expr. */
#define SOLIDSYSLOG_WINSOCK_DATAGRAM_POOL_SIZE 1U
#endif

#if SOLIDSYSLOG_WINSOCK_DATAGRAM_POOL_SIZE < 1
#error "SOLIDSYSLOG_WINSOCK_DATAGRAM_POOL_SIZE must be >= 1"
#endif

/*
* Number of SolidSyslogWinsockResolver instances the library's internal
* static pool can simultaneously hold. The resolver is stateless (its
* slot just holds the vtable); the pool exists for lifecycle symmetry
* with the stateful FreeRtosStaticResolver / GetAddrInfoResolver siblings.
*
* Default 1.
*
* Floor: 1. Sub-floor values rejected at compile time.
*/
#ifndef SOLIDSYSLOG_WINSOCK_RESOLVER_POOL_SIZE
/* NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -- macro form required for preprocessor visibility (floor #if) and C array-size const-expr. */
#define SOLIDSYSLOG_WINSOCK_RESOLVER_POOL_SIZE 1U
#endif

#if SOLIDSYSLOG_WINSOCK_RESOLVER_POOL_SIZE < 1
#error "SOLIDSYSLOG_WINSOCK_RESOLVER_POOL_SIZE must be >= 1"
#endif

/*
* Number of SolidSyslogWindowsFile instances the library's internal
* static pool can simultaneously hold. Each instance carries an `int`
* MSVC CRT file descriptor.
*
* Default 1. Integrators using FileBlockDevice with BlockStore may want
* to bump this in line with SOLIDSYSLOG_BLOCK_STORE_POOL_SIZE.
*
* Floor: 1. Sub-floor values rejected at compile time.
*/
#ifndef SOLIDSYSLOG_WINDOWS_FILE_POOL_SIZE
/* NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -- macro form required for preprocessor visibility (floor #if) and C array-size const-expr. */
#define SOLIDSYSLOG_WINDOWS_FILE_POOL_SIZE 1U
#endif

#if SOLIDSYSLOG_WINDOWS_FILE_POOL_SIZE < 1
#error "SOLIDSYSLOG_WINDOWS_FILE_POOL_SIZE must be >= 1"
#endif

/*
* Number of SolidSyslogWinsockTcpStream instances the library's internal
* static pool can simultaneously hold. Each instance carries the SOCKET
* for the non-blocking TCP connection.
*
* Default 2 — the BDD target needs a plain-TCP stream and a
* TLS-underlying-TCP stream concurrently, matching the POSIX pool size.
*
* Floor: 1. Sub-floor values rejected at compile time.
*/
#ifndef SOLIDSYSLOG_WINSOCK_TCP_STREAM_POOL_SIZE
/* NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -- macro form required for preprocessor visibility (floor #if) and C array-size const-expr. */
#define SOLIDSYSLOG_WINSOCK_TCP_STREAM_POOL_SIZE 2U
#endif

#if SOLIDSYSLOG_WINSOCK_TCP_STREAM_POOL_SIZE < 1
#error "SOLIDSYSLOG_WINSOCK_TCP_STREAM_POOL_SIZE must be >= 1"
#endif

#endif /* SOLIDSYSLOG_TUNABLES_DEFAULTS_H */
20 changes: 20 additions & 0 deletions Core/Source/SolidSyslogErrorMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,25 @@
"SolidSyslogPosixMessageQueueBuffer_Create pool exhausted; returning fallback buffer"
#define SOLIDSYSLOG_ERROR_MSG_POSIXMESSAGEQUEUEBUFFER_UNKNOWN_DESTROY \
"SolidSyslogPosixMessageQueueBuffer_Destroy called with a handle not issued by this pool"
#define SOLIDSYSLOG_ERROR_MSG_WINDOWSMUTEX_POOL_EXHAUSTED \
"SolidSyslogWindowsMutex_Create pool exhausted; returning fallback mutex"
#define SOLIDSYSLOG_ERROR_MSG_WINDOWSMUTEX_UNKNOWN_DESTROY \
"SolidSyslogWindowsMutex_Destroy called with a handle not issued by this pool"
#define SOLIDSYSLOG_ERROR_MSG_WINSOCKDATAGRAM_POOL_EXHAUSTED \
"SolidSyslogWinsockDatagram_Create pool exhausted; returning fallback datagram"
#define SOLIDSYSLOG_ERROR_MSG_WINSOCKDATAGRAM_UNKNOWN_DESTROY \
"SolidSyslogWinsockDatagram_Destroy called with a handle not issued by this pool"
#define SOLIDSYSLOG_ERROR_MSG_WINSOCKRESOLVER_POOL_EXHAUSTED \
"SolidSyslogWinsockResolver_Create pool exhausted; returning fallback resolver"
#define SOLIDSYSLOG_ERROR_MSG_WINSOCKRESOLVER_UNKNOWN_DESTROY \
"SolidSyslogWinsockResolver_Destroy called with a handle not issued by this pool"
#define SOLIDSYSLOG_ERROR_MSG_WINDOWSFILE_POOL_EXHAUSTED \
"SolidSyslogWindowsFile_Create pool exhausted; returning fallback file"
#define SOLIDSYSLOG_ERROR_MSG_WINDOWSFILE_UNKNOWN_DESTROY \
"SolidSyslogWindowsFile_Destroy called with a handle not issued by this pool"
#define SOLIDSYSLOG_ERROR_MSG_WINSOCKTCPSTREAM_POOL_EXHAUSTED \
"SolidSyslogWinsockTcpStream_Create pool exhausted; returning fallback stream"
#define SOLIDSYSLOG_ERROR_MSG_WINSOCKTCPSTREAM_UNKNOWN_DESTROY \
"SolidSyslogWinsockTcpStream_Destroy called with a handle not issued by this pool"

#endif /* SOLIDSYSLOGERRORMESSAGES_H */
Loading
Loading