Multi-client server, protocol versioning, streaming decompression #11

Merged
TapTap merged 2 commits from server-improvements into main 2026-07-16 15:15:20 +02:00
Owner

Three improvements:

1. Multi-client TCP server (transport_tcp.c, server.c)

  • server_listen now loops on accept() and forks a child per connection
  • Parent reaps children automatically via SIGCHLD=SIG_IGN
  • Signal handlers for SIGINT/SIGTERM clean up the listening socket on shutdown
  • Tested with parallel clients — both complete successfully

2. Protocol version negotiation (config.h, config.c, client_cli.c)

  • Added PROTOCOL_VERSION constant ("1.0.0")
  • Server checks client version on connect; mismatch sends STATUS_ERROR and exits
  • Client uses the constant via PROTOCOL_VERSION instead of a hardcoded string
  • Prevents silent corruption from mismatched client/server builds

3. Streaming decompression & error handling (compression.c, server.c, multiprocessing.c, file.c)

  • data_decompress now handles ZSTD_CONTENTSIZE_UNKNOWN by growing the output buffer dynamically (2x growth)
  • data_compress returns NULL instead of calling exit() on failure
  • data_decompress returns NULL instead of calling exit() on failure
  • Server receive path checks for NULL from decompression and sends STATUS_ERROR gracefully
  • Send path (file_send_single_calls) exits with a clear log message on compression failure
Three improvements: **1. Multi-client TCP server** (transport_tcp.c, server.c) - `server_listen` now loops on accept() and forks a child per connection - Parent reaps children automatically via SIGCHLD=SIG_IGN - Signal handlers for SIGINT/SIGTERM clean up the listening socket on shutdown - Tested with parallel clients — both complete successfully **2. Protocol version negotiation** (config.h, config.c, client_cli.c) - Added PROTOCOL_VERSION constant ("1.0.0") - Server checks client version on connect; mismatch sends STATUS_ERROR and exits - Client uses the constant via PROTOCOL_VERSION instead of a hardcoded string - Prevents silent corruption from mismatched client/server builds **3. Streaming decompression & error handling** (compression.c, server.c, multiprocessing.c, file.c) - data_decompress now handles ZSTD_CONTENTSIZE_UNKNOWN by growing the output buffer dynamically (2x growth) - data_compress returns NULL instead of calling exit() on failure - data_decompress returns NULL instead of calling exit() on failure - Server receive path checks for NULL from decompression and sends STATUS_ERROR gracefully - Send path (file_send_single_calls) exits with a clear log message on compression failure
TapTap added 1 commit 2026-07-16 13:59:49 +02:00
TapTap added 1 commit 2026-07-16 15:08:59 +02:00
TapTap merged commit c2436bef59 into main 2026-07-16 15:15:20 +02:00
TapTap deleted branch server-improvements 2026-07-16 15:15:23 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#11