diff --git a/library/server/ewsgi/connectors/cgi/src/wgi_cgi_output_stream.e b/library/server/ewsgi/connectors/cgi/src/wgi_cgi_output_stream.e index 0a5dea0c..a0abbb22 100644 --- a/library/server/ewsgi/connectors/cgi/src/wgi_cgi_output_stream.e +++ b/library/server/ewsgi/connectors/cgi/src/wgi_cgi_output_stream.e @@ -70,8 +70,13 @@ feature -- Status writing end end +feature -- Status report + + is_available: BOOLEAN = True + -- + 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 diff --git a/library/server/ewsgi/connectors/libfcgi/src/wgi_libfcgi_output_stream.e b/library/server/ewsgi/connectors/libfcgi/src/wgi_libfcgi_output_stream.e index cbe0f762..33987d68 100644 --- a/library/server/ewsgi/connectors/libfcgi/src/wgi_libfcgi_output_stream.e +++ b/library/server/ewsgi/connectors/libfcgi/src/wgi_libfcgi_output_stream.e @@ -38,6 +38,11 @@ feature -- Status report Result := True end +feature -- Status report + + is_available: BOOLEAN = True + -- + 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 diff --git a/library/server/ewsgi/connectors/nino/src/wgi_nino_output_stream.e b/library/server/ewsgi/connectors/nino/src/wgi_nino_output_stream.e index 3b595927..f45f9cdd 100644 --- a/library/server/ewsgi/connectors/nino/src/wgi_nino_output_stream.e +++ b/library/server/ewsgi/connectors/nino/src/wgi_nino_output_stream.e @@ -79,6 +79,15 @@ feature -- Status report Result := target.is_open_write end +feature -- Status report + + is_available: BOOLEAN + -- + -- 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 diff --git a/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e b/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e index 21d95864..1d3be84b 100644 --- a/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e +++ b/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e @@ -70,8 +70,13 @@ feature -- Status writing end end +feature -- Status report + + is_available: BOOLEAN = True + -- + 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 diff --git a/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e index b27bb173..c2f4e589 100644 --- a/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e +++ b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e @@ -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 diff --git a/library/server/ewsgi/connectors/standalone/src/httpd/network/httpd_stream_socket.e b/library/server/ewsgi/connectors/standalone/src/httpd/network/httpd_stream_socket.e index e9221910..4f4f1154 100644 --- a/library/server/ewsgi/connectors/standalone/src/httpd/network/httpd_stream_socket.e +++ b/library/server/ewsgi/connectors/standalone/src/httpd/network/httpd_stream_socket.e @@ -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 diff --git a/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e b/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e index c709ec8d..e00743a3 100644 --- a/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e +++ b/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e @@ -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 diff --git a/library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e index 7f95ec22..8fbeb459 100644 --- a/library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e @@ -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 + -- + -- 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 diff --git a/library/server/ewsgi/connectors/standalone/test_standalone-safe.ecf b/library/server/ewsgi/connectors/standalone/test_standalone-safe.ecf index cdc30795..f56141dd 100644 --- a/library/server/ewsgi/connectors/standalone/test_standalone-safe.ecf +++ b/library/server/ewsgi/connectors/standalone/test_standalone-safe.ecf @@ -10,6 +10,7 @@ + diff --git a/library/server/ewsgi/specification/response/wgi_filter_response.e b/library/server/ewsgi/specification/response/wgi_filter_response.e index 81d1b28a..f9b14d70 100644 --- a/library/server/ewsgi/specification/response/wgi_filter_response.e +++ b/library/server/ewsgi/specification/response/wgi_filter_response.e @@ -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 diff --git a/library/server/ewsgi/specification/stream/wgi_output_stream.e b/library/server/ewsgi/specification/stream/wgi_output_stream.e index 39d8dcd7..aa731ece 100644 --- a/library/server/ewsgi/specification/stream/wgi_output_stream.e +++ b/library/server/ewsgi/specification/stream/wgi_output_stream.e @@ -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 diff --git a/library/server/ewsgi/src/implementation/wgi_response_stream.e b/library/server/ewsgi/src/implementation/wgi_response_stream.e index a7610d42..73edf89a 100644 --- a/library/server/ewsgi/src/implementation/wgi_response_stream.e +++ b/library/server/ewsgi/src/implementation/wgi_response_stream.e @@ -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