First step to improve a bit error handling related to socket disconnection.
Mainly in standalone connector for now.
This commit is contained in:
@@ -70,8 +70,13 @@ feature -- Status writing
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN = True
|
||||
-- <Precursor>
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
copyright: "2011-2015, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -38,6 +38,11 @@ feature -- Status report
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN = True
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Status writing
|
||||
|
||||
put_status_line (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
|
||||
@@ -100,7 +105,7 @@ invariant
|
||||
fcgi_attached: fcgi /= Void
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
copyright: "2011-2015, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -79,6 +79,15 @@ feature -- Status report
|
||||
Result := target.is_open_write
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN
|
||||
-- <Precursor>
|
||||
-- FIXME: see how "standalone" connection is doing that.
|
||||
do
|
||||
Result := target.is_open_read
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
flush
|
||||
@@ -86,7 +95,7 @@ feature -- Basic operations
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -70,8 +70,13 @@ feature -- Status writing
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN = True
|
||||
-- <Precursor>
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
copyright: "2011-2015, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="connector_standalone" location="standalone-safe.ecf" readonly="false"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
|
||||
<library name="httpd" location="src\httpd\httpd-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\..\..\wsf\wsf-safe.ecf" readonly="false"/>
|
||||
<cluster name="tests" location="tests\" recursive="true"/>
|
||||
</target>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "[
|
||||
WGI response acting as a filter.
|
||||
WGI response acting as a filter.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -147,7 +147,7 @@ feature -- Error reporting
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -74,6 +74,12 @@ feature -- Status writing
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN
|
||||
-- Is output available?
|
||||
--| i.e: no issue with associated output stream, like closed socket, or related?
|
||||
deferred
|
||||
end
|
||||
|
||||
is_open_write: BOOLEAN
|
||||
-- Can items be written to output stream?
|
||||
deferred
|
||||
@@ -93,7 +99,7 @@ feature -- Constant
|
||||
crlf: STRING = "%R%N"
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -128,7 +128,7 @@ feature {NONE} -- Implementation: Access
|
||||
-- Server output channel
|
||||
|
||||
;note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
Reference in New Issue
Block a user