From 63be2c278c69d92a4becb060ab792f79ec7f4e2f Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 31 May 2016 22:19:52 +0200 Subject: [PATCH] Fixed bad usage of {SOCKET}.socket_ok that resulted in bad behavior on linux. --- .../src/httpd/httpd_request_handler_i.e | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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 8eaef93b..0e195c73 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 @@ -289,7 +289,12 @@ feature -- Parsing do create txt.make (64) request_header := txt - if a_socket.is_readable and then attached next_line (a_socket) as l_request_line and then not l_request_line.is_empty then + if + not has_error and then + a_socket.is_readable and then + attached next_line (a_socket) as l_request_line and then + not l_request_line.is_empty + then txt.append (l_request_line) txt.append_character ('%N') analyze_request_line (l_request_line) @@ -302,7 +307,7 @@ feature -- Parsing from line := next_line (a_socket) until - line = Void or end_of_stream + line = Void or end_of_stream or has_error loop n := line.count if l_is_verbose then @@ -372,15 +377,31 @@ feature -- Parsing next_line (a_socket: HTTPD_STREAM_SOCKET): detachable STRING -- Next line fetched from `a_socket' is available. require + not_has_error: not has_error is_readable: a_socket.is_open_read local retried: BOOLEAN do if retried then + has_error := True Result := Void - elseif a_socket.socket_ok then + elseif a_socket.readable then a_socket.read_line_thread_aware Result := a_socket.last_string + -- Do no check `socket_ok' before socket operation, + -- otherwise it may be False, due to error during other socket operation in same thread. + if not a_socket.socket_ok then + has_error := True + if is_verbose then + log ("%N## Socket is not ok! ##") + end + end + else + -- Error with socket... + has_error := True + if is_verbose then + log ("%N## Socket is not readable! ##") + end end rescue retried := True