blob: 7bed3fd8e547d6297f2d694557590f636bbdb6ab [file] [log] [blame]
Frédéric Lécaille233afc72018-09-04 15:58:14 +02001# commit 70d318c
2# BUG/MEDIUM: lua: possible CLOSE-WAIT state with '\n' headers
3#
4# The Lua parser doesn't takes in account end-of-headers containing
5# only '\n'. It expects always '\r\n'. If a '\n' is processes the Lua
6# parser considers it miss 1 byte, and wait indefinitely for new data.
7#
8# When the client reaches their timeout, it closes the connection.
9# This close is not detected and the connection keep in CLOSE-WAIT
10# state.
11#
12# I guess that this patch fix only a visible part of the problem.
13# If the Lua HTTP parser wait for data, the timeout server or the
14# connectio closed by the client may stop the applet.
15
16varnishtest "possible CLOSE-WAIT with '\n' headers"
Christopher Fauletfdafd9a2018-12-19 11:50:17 +010017#REQUIRE_OPTIONS=LUA
Frédéric Lécailledc1a3bd2019-03-29 15:07:24 +010018#REGTEST_TYPE=bug
Frédéric Lécaille233afc72018-09-04 15:58:14 +020019
20feature ignore_unknown_macro
21
22syslog Slog -level info -repeat 100 {
23 recv info
Christopher Fauletc4230302019-04-01 11:17:40 +020024 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Ta=[0-9]* Tc=[0-9]* Td=[0-9]* Th=[0-9]* Ti=[0-9]* Tq=[0-9]* TR=[0-9]* Tr=[0-9]* Tt=[0-9]* Tw=[0-9]*"
Frédéric Lécaille233afc72018-09-04 15:58:14 +020025} -start
26
27haproxy h1 -conf {
28 defaults
Willy Tarreauf6739232021-11-18 17:46:22 +010029 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
30 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécaille233afc72018-09-04 15:58:14 +020031
32 global
Frédéric Lécailleb894f922019-03-29 16:13:48 +010033 lua-load ${testdir}/close_wait_lf.lua
Frédéric Lécaille233afc72018-09-04 15:58:14 +020034
35 frontend frt
36 log ${Slog_addr}:${Slog_port} local0 debug err
37 log-format Ta=%Ta\ Tc=%Tc\ Td=%Td\ Th=%Th\ Ti=%Ti\ Tq=%Tq\ TR=%TR\ Tr=%Tr\ Tt=%Tt\ Tw=%Tw
38 mode http
Frédéric Lécaille233afc72018-09-04 15:58:14 +020039 bind "fd@${frt}"
40 http-request use-service lua.donothing
41} -start
42
43
44client c1 -connect ${h1_frt_sock} -repeat 100 {
45 send "GET / HTTP/1.1\n\n"
46} -run
47
48syslog Slog -wait
49
50shell {
Christopher Fauletce4ec502019-04-01 15:39:50 +020051 ss -pt | grep CLOSE-WAIT.*haproxy.*pid=${h1_pid}
Frédéric Lécaille233afc72018-09-04 15:58:14 +020052 exit $((!$?))
53}