diff options
author | Fredrik Gustafsson <[email protected]> | 2012-11-14 16:08:00 +0100 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2012-11-14 16:08:00 +0100 |
commit | fec356cb10757fbeb32abcfdb07f5152ca18c0de (patch) | |
tree | 53c3a08120cd3197ef0ecee74d622774c9519e31 | |
parent | c593b38ccf24ccf09b9371518da6e48d31dbc55f (diff) | |
download | otp-fec356cb10757fbeb32abcfdb07f5152ca18c0de.tar.gz otp-fec356cb10757fbeb32abcfdb07f5152ca18c0de.tar.bz2 otp-fec356cb10757fbeb32abcfdb07f5152ca18c0de.zip |
Fine adjustments of slowdos alg
-rw-r--r-- | lib/inets/src/http_server/httpd_request_handler.erl | 10 | ||||
-rw-r--r-- | lib/inets/test/httpd_basic_SUITE.erl | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/inets/src/http_server/httpd_request_handler.erl b/lib/inets/src/http_server/httpd_request_handler.erl index 56c934a0f6..5e0bd39cb3 100644 --- a/lib/inets/src/http_server/httpd_request_handler.erl +++ b/lib/inets/src/http_server/httpd_request_handler.erl @@ -277,6 +277,14 @@ handle_info(timeout, #state{mod = ModData} = State) -> error_log("The client did not send the whole request before the " "server side timeout", ModData), {stop, normal, State#state{response_sent = true}}; +handle_info(check_data_first, #state{data = Data, byte_limit = Byte_Limit} = State) -> + case Data >= (Byte_Limit*3) of + true -> + erlang:send_after(1000, self(), check_data), + {noreply, State#state{data = 0}}; + _ -> + {stop, normal, State#state{response_sent = true}} + end; handle_info(check_data, #state{data = Data, byte_limit = Byte_Limit} = State) -> case Data >= Byte_Limit of true -> @@ -631,7 +639,7 @@ data_receive_counter(State, Byte_limit) -> false -> State#state{data = 0}; Nr -> - erlang:send_after(1000, self(), check_data), + erlang:send_after(3000, self(), check_data_first), State#state{data = 0, byte_limit = Nr} end. cancel_request_timeout(#state{timer = undefined} = State) -> diff --git a/lib/inets/test/httpd_basic_SUITE.erl b/lib/inets/test/httpd_basic_SUITE.erl index 8f29745f31..f1c1c41dcb 100644 --- a/lib/inets/test/httpd_basic_SUITE.erl +++ b/lib/inets/test/httpd_basic_SUITE.erl @@ -288,7 +288,7 @@ slowdose(Config) when is_list(Config) -> Port = proplists:get_value(port, Info), {ok, Socket} = gen_tcp:connect("localhost", Port, []), receive - after 2000 -> + after 4000 -> {error, closed} = gen_tcp:send(Socket, "Hey") end. find_URL_path([]) -> |