fix(server): child-safe signals, single fd owner, handler cleanup epilogue

This commit is contained in:
2026-09-13 01:49:27 +02:00
parent b7fbb56289
commit fecbe2c90c
3 changed files with 83 additions and 80 deletions
+5
View File
@@ -192,13 +192,18 @@ static void tls_child_fn(int fd, void* arg) {
SSL* ssl = wrap_fd_with_ssl(fd, ctx->ssl_ctx, true, NULL);
if (!ssl) {
io_set_ssl(NULL);
close(fd);
return;
}
io_set_ssl(ssl);
ctx->handler(fd);
/* Shut the TLS layer down before releasing the fd: handler() no longer
* closes it, so SSL_shutdown still has a valid socket. The child owns the
* single fd close, performed last. */
SSL_shutdown(ssl);
SSL_free(ssl);
io_set_ssl(NULL);
close(fd);
}
bool server_listen_tls(Server* server, void (*handler)(int file_descriptor)) {