From: Willy Tarreau Date: Sun, 23 Nov 2008 16:23:07 +0000 (+0100) Subject: [MEDIUM] stream_interface: added a DISconnected state between CON/EST and CLO X-Git-Tag: v1.3.16-rc1~144 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74ab2ac7b0aaf7f96afd063c6e4f8a2f3653155b;p=thirdparty%2Fhaproxy.git [MEDIUM] stream_interface: added a DISconnected state between CON/EST and CLO There were rare situations where it was not easy to detect that a failed session attempt had occurred and needed some server cleanup. In particular, client aborts sometimes lead to session leaks on the server side. A new state "SI_ST_DIS" (disconnected) has been introduced for this. When a session has been closed at a stream interface but the server cleanup has not occurred, this state is entered instead of CLO. The cleanup is then performed there and the state goes to CLO. A new diagram has been added to show possible stream_interface state transitions that can occur in a stream-sock. It makes debugging easier. --- diff --git a/doc/internals/stream-sock-states.fig b/doc/internals/stream-sock-states.fig new file mode 100644 index 0000000000..63803367ad --- /dev/null +++ b/doc/internals/stream-sock-states.fig @@ -0,0 +1,417 @@ +#FIG 3.2 Produced by xfig version 3.2.5-alpha5 +Portrait +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +0 32 #8e8e8e +6 2295 1260 2430 1395 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2363 1328 68 68 2430 1328 2295 1328 +4 1 0 50 -1 18 5 0.0000 4 60 60 2363 1361 1\001 +-6 +6 1845 2295 1980 2430 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1913 2363 68 68 1980 2363 1845 2363 +4 1 0 50 -1 18 5 0.0000 4 60 60 1913 2396 2\001 +-6 +6 2475 2340 2610 2475 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2543 2408 68 68 2610 2408 2475 2408 +4 1 0 50 -1 18 5 0.0000 4 60 60 2543 2441 9\001 +-6 +6 2835 2610 2970 2745 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2903 2678 68 68 2970 2678 2835 2678 +4 1 0 50 -1 18 5 0.0000 4 60 60 2903 2711 7\001 +-6 +6 3195 2025 3330 2160 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 3263 2093 68 68 3330 2093 3195 2093 +4 1 0 50 -1 18 5 0.0000 4 60 60 3263 2126 8\001 +-6 +6 2745 2160 2880 2295 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2813 2228 68 68 2880 2228 2745 2228 +4 1 0 50 -1 18 5 0.0000 4 60 60 2813 2261 6\001 +-6 +6 990 2700 1125 2835 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1058 2768 68 68 1125 2768 990 2768 +4 1 0 50 -1 18 5 0.0000 4 60 120 1058 2801 13\001 +-6 +6 1305 2970 1440 3105 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1373 3038 68 68 1440 3038 1305 3038 +4 1 0 50 -1 18 5 0.0000 4 60 120 1373 3071 12\001 +-6 +6 3105 1710 3240 1845 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 3173 1778 68 68 3240 1778 3105 1778 +4 1 0 50 -1 18 5 0.0000 4 60 120 3173 1811 15\001 +-6 +6 4275 1260 4410 1395 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 1328 68 68 4410 1328 4275 1328 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 1361 1\001 +-6 +6 4275 1440 4410 1575 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 1508 68 68 4410 1508 4275 1508 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 1541 2\001 +-6 +6 4275 1620 4410 1755 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 1688 68 68 4410 1688 4275 1688 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 1721 3\001 +-6 +6 4275 1800 4410 1935 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 1868 68 68 4410 1868 4275 1868 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 1901 4\001 +-6 +6 3240 2835 3375 2970 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 3308 2903 68 68 3375 2903 3240 2903 +4 1 0 50 -1 18 5 0.0000 4 60 120 3308 2936 16\001 +-6 +6 2835 3015 2970 3150 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2903 3083 68 68 2970 3083 2835 3083 +4 1 0 50 -1 18 5 0.0000 4 60 120 2903 3116 17\001 +-6 +6 2295 3195 2430 3330 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2363 3263 68 68 2430 3263 2295 3263 +4 1 0 50 -1 18 5 0.0000 4 60 60 2363 3296 3\001 +-6 +6 2295 4815 2430 4950 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2363 4883 68 68 2430 4883 2295 4883 +4 1 0 50 -1 18 5 0.0000 4 60 60 2363 4916 5\001 +-6 +6 1440 4815 1620 4995 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1508 4883 68 68 1575 4883 1440 4883 +4 1 0 50 -1 18 5 0.0000 4 60 120 1508 4916 19\001 +-6 +6 1800 3960 1980 4140 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1868 4028 68 68 1935 4028 1800 4028 +4 1 0 50 -1 18 5 0.0000 4 60 120 1868 4061 18\001 +-6 +6 4275 1980 4410 2115 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 2048 68 68 4410 2048 4275 2048 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 2081 5\001 +-6 +6 4275 2340 4410 2475 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 2408 68 68 4410 2408 4275 2408 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 2441 6\001 +-6 +6 4275 2520 4410 2655 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 2588 68 68 4410 2588 4275 2588 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 2621 7\001 +-6 +6 4275 2700 4410 2835 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 2768 68 68 4410 2768 4275 2768 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 2801 8\001 +-6 +6 4275 2880 4410 3015 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 2948 68 68 4410 2948 4275 2948 +4 1 0 50 -1 18 5 0.0000 4 60 60 4343 2981 9\001 +-6 +6 4275 3060 4410 3195 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 3128 68 68 4410 3128 4275 3128 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 3161 10\001 +-6 +6 4275 3240 4410 3375 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 3308 68 68 4410 3308 4275 3308 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 3341 11\001 +-6 +6 4275 3420 4410 3555 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 3488 68 68 4410 3488 4275 3488 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 3521 12\001 +-6 +6 4275 3600 4410 3735 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 3668 68 68 4410 3668 4275 3668 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 3701 13\001 +-6 +6 4275 3960 4410 4095 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 4028 68 68 4410 4028 4275 4028 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 4061 15\001 +-6 +6 4275 4140 4410 4275 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 4208 68 68 4410 4208 4275 4208 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 4241 16\001 +-6 +6 4275 4320 4410 4455 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 4388 68 68 4410 4388 4275 4388 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 4421 17\001 +-6 +6 4275 3780 4455 3960 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 3848 68 68 4410 3848 4275 3848 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 3881 14\001 +-6 +6 4275 4590 4455 4770 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 4658 68 68 4410 4658 4275 4658 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 4691 18\001 +-6 +6 4275 4770 4455 4950 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 4838 68 68 4410 4838 4275 4838 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 4871 19\001 +-6 +6 4275 4950 4455 5130 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 5018 68 68 4410 5018 4275 5018 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 5051 20\001 +-6 +6 2295 5670 2475 5850 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2363 5738 68 68 2430 5738 2295 5738 +4 1 0 50 -1 18 5 0.0000 4 60 120 2363 5771 20\001 +-6 +6 1170 3690 1350 3870 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1238 3758 68 68 1305 3758 1170 3758 +4 1 0 50 -1 18 5 0.0000 4 60 120 1238 3791 11\001 +-6 +6 1530 3555 1710 3735 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 1598 3623 68 68 1665 3623 1530 3623 +4 1 0 50 -1 18 5 0.0000 4 60 120 1598 3656 10\001 +-6 +6 720 4095 900 4275 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 788 4163 68 68 855 4163 720 4163 +4 1 0 50 -1 18 5 0.0000 4 60 120 788 4196 14\001 +-6 +6 855 3645 1035 3825 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 923 3713 68 68 990 3713 855 3713 +4 1 0 50 -1 18 5 0.0000 4 60 120 923 3746 21\001 +-6 +6 4275 5130 4455 5310 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 5198 68 68 4410 5198 4275 5198 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 5231 21\001 +-6 +6 2295 4140 2430 4275 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2363 4208 68 68 2430 4208 2295 4208 +4 1 0 50 -1 18 5 0.0000 4 60 60 2363 4241 4\001 +-6 +6 2475 3870 2655 4050 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 2543 3938 68 68 2610 3938 2475 3938 +4 1 0 50 -1 18 5 0.0000 4 60 120 2543 3971 22\001 +-6 +6 4275 5310 4455 5490 +1 4 0 1 0 7 50 -1 -1 0.000 1 0.0000 4343 5378 68 68 4410 5378 4275 5378 +4 1 0 50 -1 18 5 0.0000 4 60 120 4343 5411 22\001 +-6 +1 2 0 1 0 6 50 -1 20 0.000 1 0.0000 1350 4612 225 112 1125 4612 1575 4612 +1 2 0 1 0 6 50 -1 20 0.000 1 0.0000 2250 5422 225 112 2025 5422 2475 5422 +1 2 0 1 0 6 50 -1 20 0.000 1 0.0000 2250 1912 225 112 2025 1912 2475 1912 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 1125 3487 225 112 900 3487 1350 3487 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2250 3712 225 112 2025 3712 2475 3712 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2250 4612 225 112 2025 4612 2475 4612 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2250 6187 225 112 2025 6187 2475 6187 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2250 2812 225 112 2025 2812 2475 2812 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 3375 2362 225 112 3150 2362 3600 2362 +1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2250 1012 225 112 2025 1012 2475 1012 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 2250 1125 2250 1800 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 2250 4725 2250 5310 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 2250 5535 2250 6075 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 8550 5805 4500 5805 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 + 6885 5900 6930 5990 6975 5810 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 + 7605 5890 7650 5980 7695 5800 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 8550 6030 4500 6030 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5310 5580 5310 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5670 5580 5670 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 6030 5580 6030 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 6390 5580 6390 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 6750 5580 6750 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 7110 5580 7110 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 7470 5580 7470 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 7830 5580 7830 6705 +2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 4950 5580 4950 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 8550 6255 4500 6255 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 8550 6480 4500 6480 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4500 5580 8550 5580 8550 6705 4500 6705 4500 5580 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 8190 5580 8190 6705 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 + 6885 6570 6930 6660 6975 6480 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 + 7605 6570 7650 6660 7695 6480 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 + 7965 6570 8010 6660 8055 6480 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 2475 2835 3150 3375 3150 5625 2475 6120 + 0.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 2250 2700 2475 2475 2475 2250 2250 2025 + 0.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 3 + 1 1 1.00 60.00 120.00 + 3375 2250 2925 2025 2475 1935 + 0.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 3 + 1 1 1.00 60.00 120.00 + 3375 2475 3375 2700 2475 2835 + 0.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 3420 2475 3420 4320 3150 5850 2475 6165 + 0.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 3 + 1 1 1.00 60.00 120.00 + 1125 3375 1125 2925 2025 2790 + 0.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 3 + 1 1 1.00 60.00 120.00 + 1125 3375 1125 2250 2025 1935 + 0.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 6 + 1 1 1.00 60.00 120.00 + 2475 1890 3825 1800 3825 2520 3825 4500 3150 6075 2475 6210 + 0.000 1.000 1.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 2250 2025 2025 2250 2025 2475 2250 2700 + 0.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 2 + 1 1 1.00 60.00 120.00 + 2250 3825 2250 4500 + 0.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 3 + 1 1 1.00 60.00 120.00 + 2475 1980 2880 2115 3150 2340 + 0.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 2 + 1 1 1.00 60.00 120.00 + 2250 2925 2250 3600 + 0.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 2205 3825 2070 4140 1622 4221 1440 4500 + 0.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 1350 4725 1350 4950 1485 5760 2025 6165 + 0.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 7 + 1 1 1.00 60.00 120.00 + 1125 4590 720 4455 675 4050 675 3600 675 2250 1350 1800 + 2025 1935 + 0.000 1.000 1.000 1.000 1.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 3 + 1 1 1.00 60.00 120.00 + 1260 4500 1125 4320 1125 3600 + 0.000 1.000 0.000 +3 0 0 1 0 7 50 -1 -1 0.000 0 1 0 4 + 1 1 1.00 60.00 120.00 + 1350 4500 1440 3645 1575 3330 2070 2880 + 0.000 1.000 1.000 0.000 +3 0 0 1 32 7 51 -1 -1 0.000 0 1 0 5 + 1 1 1.00 60.00 120.00 + 1035 3600 990 4365 990 5040 1395 5895 2025 6210 + 0.000 1.000 1.000 1.000 0.000 +3 0 0 1 32 7 51 -1 -1 0.000 0 1 0 5 + 1 1 1.00 60.00 120.00 + 2340 3825 2385 4005 2925 4275 2655 4815 2295 5310 + 0.000 1.000 1.000 1.000 0.000 +4 0 0 50 -1 14 6 0.0000 4 90 2880 4500 1710 ASS-CON: ssui(): connect_server() == SN_ERR_NONE\001 +4 0 0 50 -1 14 6 0.0000 4 75 540 4500 1350 INI-REQ: \001 +4 0 0 50 -1 14 6 0.0000 4 90 3720 4500 1530 REQ-ASS: prepare_conn_request(): srv_redispatch_connect() == 0\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2475 2700 4\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 1620 4500 6\001 +4 0 0 50 -1 14 6 0.0000 4 90 3360 4500 1890 CON-EST: sess_update_st_con_tcp(): !timeout && !conn_err\001 +4 0 0 50 -1 14 6 0.0000 4 90 2460 4500 3510 TAR-ASS: ssui(): SI_FL_EXP && SN_ASSIGNED\001 +4 0 0 50 -1 14 6 0.0000 4 90 3420 4500 2970 ASS-REQ: connect_server: conn_retries == 0 && PR_O_REDISP\001 +4 0 0 50 -1 14 6 0.0000 4 90 2460 4500 2610 QUE-REQ: ssui(): !pend_pos && SN_ASSIGNED\001 +4 0 0 50 -1 14 6 0.0000 4 90 2520 4500 2790 QUE-REQ: ssui(): !pend_pos && !SN_ASSIGNED\001 +4 0 0 50 -1 14 6 0.0000 4 90 3300 4500 4230 QUE-CLO: ssui(): pend_pos && (SI_FL_EXP || req_aborted)\001 +4 0 0 50 -1 14 6 0.0000 4 90 2520 4500 3690 TAR-REQ: ssui(): SI_FL_EXP && !SN_ASSIGNED\001 +4 0 0 50 -1 14 6 0.0000 4 90 3960 4500 4545 ASS-CLO: PR_O_REDISP && SN_REDIRECTABLE && perform_http_redirect()\001 +4 0 0 50 -1 14 6 0.0000 4 90 4440 4500 2430 REQ-QUE: prepare_conn_request(): srv_redispatch_connect() != 0 (SI_ST_QUE)\001 +4 0 0 50 -1 14 6 0.0000 4 90 4200 4500 4050 REQ-CLO: prepare_conn_request(): srv_redispatch_connect() != 0 (error)\001 +4 0 0 50 -1 14 6 0.0000 4 90 4320 4500 4410 ASS-CLO: ssui(): connect_server() == SN_ERR_INTERNAL || conn_retries < 0\001 +4 0 0 50 -1 14 6 0.0000 4 90 3120 4500 4680 CON-CER: sess_update_st_con_tcp(): timeout/SI_FL_ERR\001 +4 0 0 50 -1 14 6 0.0000 4 90 3600 4500 4860 CER-CLO: sess_update_st_cer(): (ERR/EXP) && conn_retries < 0\001 +4 0 0 50 -1 14 6 0.0000 4 90 4200 4500 3870 CER-REQ: sess_update_st_cer(): timeout && !conn_retries && PR_O_REDISP\001 +4 0 0 50 -1 14 6 0.0000 4 90 3600 4500 3330 CER-TAR: sess_update_st_cer(): conn_err && conn_retries >= 0\001 +4 0 0 50 -1 14 6 0.0000 4 90 4620 4500 3150 CER-ASS: sess_update_st_cer(): timeout && (conn_retries >= 0 || !PR_O_REDISP)\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 1305 3375 3\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2430 4500 7\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2430 3600 5\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 3555 2250 2\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2430 1800 1\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2430 900 0\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2430 5310 8\001 +4 0 0 50 -1 14 6 0.0000 4 90 3000 4500 2070 EST-DIS: stream_sock_read/write/shutr/shutw: close\001 +4 0 0 50 -1 14 6 0.0000 4 90 1980 4500 2250 EST-DIS: process_session(): error\001 +4 0 0 50 -1 14 6 0.0000 4 90 2100 4500 5040 DIS-CLO: process_session(): cleanup\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 2250 5490 DIS\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 1350 4680 CER\001 +4 1 0 50 -1 14 10 0.0000 4 105 270 2250 1980 REQ\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 1125 3555 TAR\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 2250 2880 ASS\001 +4 1 0 50 -1 14 10 0.0000 4 105 270 3375 2430 QUE\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 2250 3780 CON\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 2250 4680 EST\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 2250 6255 CLO\001 +4 1 0 50 -1 14 10 0.0000 4 90 270 2250 1080 INI\001 +4 0 0 50 -1 14 6 0.0000 4 90 2820 4500 5220 TAR-CLO: sess_update_stream_int(): client abort\001 +4 0 4 50 -1 14 10 0.0000 4 105 90 2385 6075 9\001 +4 0 0 50 -1 16 6 0.0000 4 120 5970 675 6885 Note: states painted yellow above are transient ; process_session() will never leave a stream interface in any of those upon return.\001 +4 0 0 50 -1 14 6 0.0000 4 90 2820 4500 5400 CON-DIS: sess_update_st_con_tcp(): client abort\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 5130 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 5490 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 5850 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 6210 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 6570 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 7290 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 8010 5985 -\001 +4 1 0 50 -1 16 7 0.0000 4 105 120 4725 5985 fd\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 5130 5760 INI\001 +4 1 0 50 -1 16 7 0.0000 4 105 270 4725 5760 state\001 +4 1 0 50 -1 14 8 0.0000 4 90 225 5490 5760 REQ\001 +4 1 0 50 -1 14 8 0.0000 4 90 225 5850 5760 QUE\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 6210 5760 TAR\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 6570 5760 ASS\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 6930 5760 CON\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 7290 5760 CER\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 7650 5760 EST\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 8010 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 90 75 5850 6210 0\001 +4 1 0 50 -1 14 8 0.0000 4 90 75 5130 6210 0\001 +4 1 0 50 -1 16 7 0.0000 4 90 270 4725 6210 ERR\001 +4 1 0 50 -1 16 7 0.0000 4 90 270 4725 6435 EXP\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 8010 6435 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 5490 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 6210 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 6570 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 6570 6435 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 5490 6435 X\001 +4 1 0 50 -1 14 8 0.0000 4 90 75 5130 6435 0\001 +4 1 0 50 -1 14 8 0.0000 4 90 75 5850 6435 0\001 +4 1 0 50 -1 14 8 0.0000 4 90 75 6210 6435 0\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 7290 6435 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 6930 6435 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 7290 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 6930 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 7650 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 7650 6435 X\001 +4 1 0 50 -1 16 7 0.0000 4 75 240 4725 6660 sess\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 8370 5760 CLO\001 +4 1 0 50 -1 14 8 0.0000 4 75 225 8010 5760 DIS\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 8370 5985 -\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 8370 6210 X\001 +4 1 0 50 -1 14 8 0.0000 4 75 75 8370 6435 X\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 5130 6660 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 5490 6660 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 5850 6660 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 6210 6660 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 6570 6660 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 7290 6660 -\001 +4 1 0 50 -1 14 8 0.0000 4 15 75 8370 6660 -\001 diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h index fbd2ab06c4..111ffc740c 100644 --- a/include/types/stream_interface.h +++ b/include/types/stream_interface.h @@ -29,17 +29,19 @@ /* A stream interface must have its own errors independantly of the buffer's, * so that applications can rely on what the buffer reports while the stream - * interface is performing some retries (eg: connection error). + * interface is performing some retries (eg: connection error). Some states are + * transient and do not last beyond process_session(). */ enum { SI_ST_INI = 0, /* interface not sollicitated yet */ - SI_ST_REQ, /* connection initiation desired and not started yet */ + SI_ST_REQ, /* [transient] connection initiation desired and not started yet */ SI_ST_QUE, /* interface waiting in queue */ SI_ST_TAR, /* interface in turn-around state after failed connect attempt */ SI_ST_ASS, /* server just assigned to this interface */ SI_ST_CON, /* initiated connection request (resource exists) */ - SI_ST_CER, /* previous connection attempt failed (resource released) */ + SI_ST_CER, /* [transient] previous connection attempt failed (resource released) */ SI_ST_EST, /* connection established (resource exists) */ + SI_ST_DIS, /* [transient] disconnected from other side, but cleanup not done yet */ SI_ST_CLO, /* stream intf closed, might not existing anymore. Buffers shut. */ }; diff --git a/src/proto_http.c b/src/proto_http.c index a3a7817166..df905e2713 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -700,6 +700,8 @@ void sess_update_stream_int(struct session *s, struct stream_interface *si) si->ob->flags |= BF_WRITE_ERROR; s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now); + + /* no session was ever accounted for this server */ si->state = SI_ST_CLO; return; } @@ -963,7 +965,7 @@ void process_session(struct task *t, int *next) */ if (s->si[0].state == SI_ST_EST) { if (unlikely(s->si[0].flags & SI_FL_ERR)) { - s->si[0].state = SI_ST_CLO; + s->si[0].state = SI_ST_DIS; fd_delete(s->si[0].fd); stream_int_report_error(&s->si[0]); } @@ -971,7 +973,7 @@ void process_session(struct task *t, int *next) if (s->si[1].state == SI_ST_EST) { if (unlikely(s->si[1].flags & SI_FL_ERR)) { - s->si[1].state = SI_ST_CLO; + s->si[1].state = SI_ST_DIS; fd_delete(s->si[1].fd); stream_int_report_error(&s->si[1]); /////////// FIXME: the following must move somewhere else @@ -980,7 +982,7 @@ void process_session(struct task *t, int *next) s->srv->failed_resp++; } } - else if (s->si[1].state != SI_ST_INI && s->si[1].state != SI_ST_CLO) { + else if (s->si[1].state >= SI_ST_QUE && s->si[1].state <= SI_ST_CON) { /* Maybe we were trying to establish a connection on the server side ? */ if (s->si[1].state == SI_ST_CON) { if (unlikely(!sess_update_st_con_tcp(s, &s->si[1]))) @@ -1010,8 +1012,8 @@ void process_session(struct task *t, int *next) /////// FIXME: do that later /* FIXME: we might have got errors above, and we should process them below */ - if (s->si[1].state == SI_ST_CLO && s->si[1].prev_state != SI_ST_CLO && - s->si[1].err_type != SI_ET_NONE) + if ((s->si[1].state == SI_ST_DIS || s->si[1].state == SI_ST_CLO) && + s->si[1].prev_state != SI_ST_CLO && s->si[1].err_type != SI_ET_NONE) return_srv_error(s, s->si[1].err_type); @@ -1078,14 +1080,29 @@ void process_session(struct task *t, int *next) /* 3: When a server-side connection is released, we have to * count it and check for pending connections on this server. */ - if (unlikely(s->req->cons->state == SI_ST_CLO && s->srv && (s->flags & SN_CURR_SESS))) { - s->flags &= ~SN_CURR_SESS; - s->srv->cur_sess--; - sess_change_server(s, NULL); - if (may_dequeue_tasks(s->srv, s->be)) - process_srv_queue(s->srv); + if (unlikely(s->req->cons->state == SI_ST_DIS)) { + s->req->cons->state = SI_ST_CLO; + if (s->srv) { + if (s->flags & SN_CURR_SESS) { + s->flags &= ~SN_CURR_SESS; + s->srv->cur_sess--; + } + sess_change_server(s, NULL); + if (may_dequeue_tasks(s->srv, s->be)) + process_srv_queue(s->srv); + } } + /* nothing special to be done on client side */ + if (unlikely(s->req->prod->state == SI_ST_DIS)) + s->req->prod->state = SI_ST_CLO; + + /* + * Note: all transient states (REQ, CER, DIS) have been eliminated at + * this point. + */ + + /* Dirty trick: force one first pass everywhere */ rqf_cli = rqf_srv = ~s->req->flags; rpf_cli = rpf_srv = ~s->rep->flags; @@ -1163,7 +1180,8 @@ void process_session(struct task *t, int *next) /* When a server-side connection is released, we have to * count it and check for pending connections on this server. */ - if (s->req->cons->state == SI_ST_CLO) { + if (s->req->cons->state == SI_ST_DIS) { + s->req->cons->state = SI_ST_CLO; if (s->srv) { if (s->flags & SN_CURR_SESS) { s->flags &= ~SN_CURR_SESS; @@ -3722,7 +3740,7 @@ int process_response(struct session *t) /* This function is called with (si->state == SI_ST_CON) meaning that a * connection was attempted and that the file descriptor is already allocated. * We must check for establishment, error and abort. Possible output states - * are SI_ST_EST (established), SI_ST_CER (error), SI_ST_CLO (abort), and + * are SI_ST_EST (established), SI_ST_CER (error), SI_ST_DIS (abort), and * SI_ST_CON (no change). The function returns 0 if it switches to SI_ST_CER, * otherwise 1. */ @@ -3770,7 +3788,7 @@ int sess_update_st_con_tcp(struct session *s, struct stream_interface *si) fd_delete(si->fd); buffer_shutw(req); buffer_shutr(rep); - si->state = SI_ST_CLO; + si->state = SI_ST_DIS; si->err_type |= SI_ET_CONN_ABRT; si->err_loc = s->srv; return 1; diff --git a/src/stream_sock.c b/src/stream_sock.c index 4de51ee2cb..a23d0fd321 100644 --- a/src/stream_sock.c +++ b/src/stream_sock.c @@ -81,7 +81,7 @@ int stream_sock_read(int fd) { if (max > b->rlim - b->data) max = b->rlim - b->data; } - + if (unlikely(max == 0)) { /* Not anymore room to store data. This should theorically * never happen, but better safe than sorry ! @@ -115,7 +115,7 @@ int stream_sock_read(int fd) { cur_read += ret; b->flags |= BF_READ_PARTIAL; b->flags &= ~BF_EMPTY; - + if (b->r == b->data + BUFSIZE) { b->r = b->data; /* wrap around the buffer */ } @@ -272,7 +272,7 @@ int stream_sock_read(int fd) { goto wakeup_return; do_close_and_return: - si->state = SI_ST_CLO; + si->state = SI_ST_DIS; fd_delete(fd); wakeup_return: task_wakeup(si->owner, TASK_WOKEN_IO); @@ -370,12 +370,12 @@ int stream_sock_write(int fd) { if (ret > 0) { b->l -= ret; b->w += ret; - + b->flags |= BF_WRITE_PARTIAL; if (b->l < b->rlim - b->data) b->flags &= ~BF_FULL; - + if (b->w == b->data + BUFSIZE) { b->w = b->data; /* wrap around the buffer */ } @@ -461,7 +461,7 @@ int stream_sock_write(int fd) { goto wakeup_return; do_close_and_return: - si->state = SI_ST_CLO; + si->state = SI_ST_DIS; fd_delete(fd); wakeup_return: task_wakeup(si->owner, TASK_WOKEN_IO); @@ -485,7 +485,7 @@ int stream_sock_shutw(struct stream_interface *si) if (si->ib->flags & BF_SHUTR) { fd_delete(si->fd); - si->state = SI_ST_CLO; + si->state = SI_ST_DIS; return 1; } EV_FD_CLR(si->fd, DIR_WR); @@ -510,7 +510,7 @@ int stream_sock_shutr(struct stream_interface *si) if (si->ob->flags & BF_SHUTW) { fd_delete(si->fd); - si->state = SI_ST_CLO; + si->state = SI_ST_DIS; return 1; } EV_FD_CLR(si->fd, DIR_RD); @@ -543,7 +543,7 @@ int stream_sock_data_update(int fd) buffer_shutr(ib); if (ob->flags & BF_SHUTW) { fd_delete(fd); - ob->cons->state = SI_ST_CLO; + ob->cons->state = SI_ST_DIS; return 0; } EV_FD_CLR(fd, DIR_RD); @@ -559,7 +559,7 @@ int stream_sock_data_update(int fd) buffer_shutw(ob); if (ib->flags & BF_SHUTR) { fd_delete(fd); - ob->cons->state = SI_ST_CLO; + ob->cons->state = SI_ST_DIS; return 0; } EV_FD_CLR(fd, DIR_WR);