One thread per connection plus max_inflight upstream slots; further requests wait in
line (queue_timeout) instead of being refused. A waiting caller that asked for a
stream is told why it waits with SSE comment lines (': junction: waiting for a free
slot (0 ahead of you)'), which the spec says every parser must ignore — a human
watching curl sees progress, a client sees nothing it could misinterpret. The real
answer then starts in the same stream and the comments simply stop.
Trade-off, stated in the README: a streaming caller gets its 200 before the upstream
is chosen, so a later upstream failure cannot be an HTTP status any more — it travels
as a data: {"error":...} event. Non-streaming callers get nothing injected and keep
their true status code.
Also: cache and endpoint state are locked (they are shared between threads now), and
the test stub forks per connection — a serial stub made a concurrent router look
serialised, which is exactly the kind of test that lies.
55 lines
1.6 KiB
Makefile
55 lines
1.6 KiB
Makefile
# junction — C99 + POSIX. TLS is optional: an OpenSSL build adds https:// upstreams
|
|
# and a TLS listener; J_WITH_TLS=0 gives a dependency-free binary.
|
|
CC ?= cc
|
|
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Wpedantic -Wshadow -Wconversion
|
|
CPPFLAGS += -D_POSIX_C_SOURCE=200809L
|
|
CFLAGS += -pthread
|
|
LDFLAGS += -pthread
|
|
LDFLAGS ?=
|
|
PREFIX ?= /usr/local
|
|
J_WITH_TLS ?= auto
|
|
|
|
SRC = src/config.c src/conn.c src/http.c src/cache.c src/junction.c
|
|
OBJ = $(SRC:.c=.o)
|
|
TOOLS = tools/junction-wol
|
|
|
|
ifeq ($(J_WITH_TLS),0)
|
|
TLS_LIBS =
|
|
else
|
|
ifeq ($(wildcard /usr/include/openssl/ssl.h),)
|
|
TLS_LIBS =
|
|
else
|
|
CPPFLAGS += -DJ_HAVE_TLS
|
|
TLS_LIBS = -lssl -lcrypto
|
|
endif
|
|
endif
|
|
|
|
all: junction $(TOOLS)
|
|
|
|
tools/junction-wol: tools/junction-wol.c
|
|
$(CC) -std=c99 -O2 -Wall -Wextra -Wpedantic $< -o $@
|
|
|
|
junction: $(OBJ)
|
|
$(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS) $(TLS_LIBS)
|
|
|
|
src/%.o: src/%.c src/config.h src/conn.h src/http.h src/cache.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
test: junction
|
|
tests/run.sh
|
|
|
|
install: junction $(TOOLS)
|
|
install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/junction/hooks
|
|
install -m 0755 junction $(DESTDIR)$(PREFIX)/bin/junction
|
|
install -m 0755 $(TOOLS) $(DESTDIR)$(PREFIX)/bin/junction-wol
|
|
install -m 0755 hooks/*.sh $(DESTDIR)$(PREFIX)/share/junction/hooks/
|
|
install -m 0755 $(TOOLS) $(DESTDIR)$(PREFIX)/share/junction/hooks/
|
|
install -m 0644 config.example $(DESTDIR)$(PREFIX)/share/junction/junction.conf
|
|
install -d $(DESTDIR)$(PREFIX)/share/junction/examples
|
|
install -m 0644 examples/*.conf $(DESTDIR)$(PREFIX)/share/junction/examples/
|
|
|
|
clean:
|
|
rm -f $(OBJ) junction $(TOOLS)
|
|
|
|
.PHONY: all test install clean
|