First step to improve a bit error handling related to socket disconnection.

Mainly in standalone connector for now.
This commit is contained in:
2015-04-01 17:29:53 +02:00
parent 9d20e85c03
commit 89e26519e4
12 changed files with 82 additions and 13 deletions

View File

@@ -176,6 +176,7 @@ feature -- Execution
l_remote_info: detachable like remote_info
l_continue: BOOLEAN
l_socket: like client_socket
l_ready_for_reading: BOOLEAN
do
l_socket := client_socket
check
@@ -190,9 +191,11 @@ feature -- Execution
debug ("dbglog")
dbglog (generator + ".execute_request socket=" + l_socket.descriptor.out + " ENTER")
end
l_socket.set_timeout (5) -- 5 seconds!
from until l_continue loop
if l_socket.try_ready_for_reading then
-- ready_for_reading then
-- Use timeout from l_socket!
l_ready_for_reading := l_socket.ready_for_reading
if l_ready_for_reading then
l_continue := True
create l_remote_info
if attached l_socket.peer_address as l_addr then

View File

@@ -46,12 +46,27 @@ feature {NONE} -- Initialization
do
Result := s.socket.descriptor
end
feature -- Change
set_timeout (n: INTEGER)
do
if attached {NETWORK_STREAM_SOCKET} socket as l_socket then
l_socket.set_timeout (n)
end
end
set_connect_timeout (n: INTEGER)
do
if attached {NETWORK_STREAM_SOCKET} socket as l_socket then
l_socket.set_connect_timeout (n)
end
end
set_accept_timeout (n: INTEGER)
do
if attached {NETWORK_STREAM_SOCKET} socket as l_socket then
l_socket.set_accept_timeout (500_000)
l_socket.set_accept_timeout (n)
end
end

View File

@@ -62,7 +62,7 @@ feature -- Request processing
-- Process request ...
local
l_input: WGI_INPUT_STREAM
l_output: WGI_OUTPUT_STREAM
l_output: detachable WGI_OUTPUT_STREAM
l_error: WGI_ERROR_STREAM
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_STANDALONE_RESPONSE_STREAM
@@ -84,12 +84,15 @@ feature -- Request processing
res.push
exec.clean
else
process_rescue (res)
if not has_error then
process_rescue (res)
end
if exec /= Void then
exec.clean
end
end
rescue
has_error := l_output = Void or else not l_output.is_available
if not retried then
retried := True
retry

View File

@@ -26,6 +26,7 @@ feature {NONE} -- Initialization
make (a_target: like target)
do
set_target (a_target)
last_target_call_succeed := True
end
feature {WGI_STANDALONE_CONNECTOR, WGI_SERVICE} -- Nino
@@ -37,6 +38,9 @@ feature {WGI_STANDALONE_CONNECTOR, WGI_SERVICE} -- Nino
target: HTTPD_STREAM_SOCKET
last_target_call_succeed: BOOLEAN
-- Last target call succeed?
feature -- Status writing
put_status_line (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
@@ -65,22 +69,35 @@ feature -- Output
put_readable_string_8 (s: READABLE_STRING_8)
-- Send `s' to http client
do
last_target_call_succeed := False
target.put_readable_string_8 (s)
last_target_call_succeed := True
end
put_string (s: READABLE_STRING_8)
-- Send `s' to http client
do
last_target_call_succeed := False
target.put_readable_string_8 (s)
last_target_call_succeed := True
end
put_character (c: CHARACTER_8)
do
last_target_call_succeed := False
target.put_character (c)
last_target_call_succeed := True
end
feature -- Status report
is_available: BOOLEAN
-- <Precursor>
-- for instance IO failure due to socket disconnection.
do
Result := not last_target_call_succeed
end
is_open_write: BOOLEAN
-- Can items be written to output stream?
do