diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-02 00:53:24 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-02 00:53:24 +0300 |
| commit | 58602a28d2c92b603208f3e01c14c169d28cc7b0 (patch) | |
| tree | 502d2e187ea29f2cc840e22d299d752d59088a3c /yhttpd/Dockerfile | |
| parent | 6c3a65b577f002f3219d03498c66205434765179 (diff) | |
yhttpd: port ychat fixes, get it building + stable in Docker (task 9s0)
Ports the ychat revival fixes (unsigned/size_t npos truncation, ofstream
== NULL, tool::trim OOB, CGI popen -> execve, www.yChat.org links, g++
version gate, config.pl -I., NCURSES/CLI-disabled build) so yhttpd builds
on modern GCC in a Rocky Linux 9 container, plus yhttpd-specific fixes
found while verifying it under concurrent load:
- listen() backlog was hardcoded to 1; bumped to SOMAXCONN.
- sock::_close() closed sockets with unread request bytes still in the
kernel receive buffer (read_http() only reads the GET line), so Linux
sent an abortive RST instead of a FIN, racing the client's read of the
response ("connection reset by peer" even though it was delivered).
Fixed with a non-blocking, bounded drain before close() - confirmed via
tcpdump: RSTs on every response before, zero after, across 140+
requests / concurrent bursts of 20.
- Removed a duplicate _make_server_socket() call in start() (wrap.cpp's
init_wrapper() already makes it before start() runs) that leaked a fd
and would have double-initialized SSL if OPENSSL is ever enabled;
caught by fresh-context review, documented honestly in DOCKER.md.
- src/configure's dependency-checker predates 64-bit multilib distros
(only checked /usr/lib, never /usr/lib64) and was missing an ncur
move-aside entry for the NCURSES-disabled build.
Added Dockerfile/.dockerignore/DOCKER.md documenting the build, the fixes,
and the one known-but-unfixed landmine (a SIGILL heap corruption in
sock::_close that reproduces on newer host GCC/glibc but not in the
container - latent, not fixed).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'yhttpd/Dockerfile')
| -rw-r--r-- | yhttpd/Dockerfile | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/yhttpd/Dockerfile b/yhttpd/Dockerfile new file mode 100644 index 0000000..515932f --- /dev/null +++ b/yhttpd/Dockerfile @@ -0,0 +1,56 @@ +# yhttpd — Docker build (revival) +# +# yhttpd is a minimal httpd derived from ychat's socket/engine. This image +# builds it entirely in a container on Rocky Linux 9 (its bespoke perl build +# system was gated to g++ 3.x; the configure now accepts any GNU g++). +# +# NCURSES and CLI are disabled (glob.h) so the build needs no ncurses and +# produces a pure httpd. The server listens on port 2000 (httpd.serverport). +# +# STATUS: with the ported fixes yhttpd now BUILDS on a modern toolchain and +# serves requests without crashing when built+run here (Rocky Linux 9 / +# GCC 11). A SIGILL heap-corruption crash in sock::_close DOES reproduce +# when built on a newer host toolchain (GCC 16) - see yhttpd/DOCKER.md for +# why this doesn't mean it's fixed. Concurrent bursts still see some +# connection resets (not crashes). See yhttpd/DOCKER.md for details. + +# ---------- builder ---------- +FROM rockylinux:9 AS builder + +RUN dnf -y install \ + gcc-c++ \ + make \ + perl \ + which \ + libevent-devel \ + && dnf clean all + +WORKDIR /build/yhttpd +COPY . . +RUN rm -rf obj bin backuped g++.version make.version src/Makefile src/includes.add src/libs.add + +# config.pl is interactive (asks yes/no); "yes" = use default before-compile +# options (keeps our glob.h: NCURSES/CLI disabled). src/configure scans glob.h +# and drops the ncur/ + cli/ sources from the build accordingly. +RUN echo yes | ./configure \ + && make + +# ---------- runtime ---------- +FROM rockylinux:9 AS runtime + +RUN dnf -y install libevent libstdc++ tzdata ca-certificates \ + && dnf clean all + +RUN useradd -r -u 1000 -d /app -s /sbin/nologin yhttpd + +WORKDIR /app +COPY --from=builder /build/yhttpd/bin /app/bin/yhttpd +COPY --from=builder /build/yhttpd/etc/ /app/etc/ +COPY --from=builder /build/yhttpd/html/ /app/html/ + +RUN mkdir -p /app/log && chown -R yhttpd:yhttpd /app + +USER 1000:1000 +EXPOSE 2000 + +ENTRYPOINT ["/app/bin/yhttpd"]
\ No newline at end of file |
