Skip to content

Commit 7e9208c

Browse files
committed
generic_unix: use a graceful close for TCP server sockets
Fix a behavior with init_server_tcp_socket that surfaced in FreeBSD CI failures. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 2903b59 commit 7e9208c

2 files changed

Lines changed: 1 addition & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7070
- Fixed several underallocation issues that could trigger data corruption on `binary:replace`, `zlib:compress` and bsd socket recv code.
7171
- Fixed a bug where `catch` would raise on regular atom results
7272
- Fixed ESP32 socket driver holding the global socket-list lock across blocking TCP connects, leaking the port on connect failure, losing concurrent `accept` waiters, leaking `netbuf` on receive error paths, and a recycled-`netconn` race between socket close and the event handler
73+
- Fixed generic_unix TCP server sockets performing an abortive close that could truncate replies awaiting ack
7374

7475
## [0.7.0-alpha.1] - 2026-04-06
7576

src/platforms/generic_unix/lib/socket_driver.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,8 @@ static term init_server_tcp_socket(Context *ctx, SocketDriverData *socket_data,
367367
}
368368
socket_data->sockfd = sockfd;
369369

370-
//
371-
// set socket options:
372-
// reuse-address
373-
// disable linger
374-
//
375370
int flag = 1;
376371
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &flag, sizeof(int));
377-
struct linger sl;
378-
sl.l_onoff = 1;
379-
sl.l_linger = 0;
380-
setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &sl, sizeof(sl));
381372

382373
if (fcntl(socket_data->sockfd, F_SETFL, O_NONBLOCK) == -1) {
383374
close(sockfd);

0 commit comments

Comments
 (0)