Skip to content

Commit 63be2c2

Browse files
committed
Fixed bad usage of {SOCKET}.socket_ok that resulted in bad behavior on linux.
1 parent f8ba741 commit 63be2c2

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,12 @@ feature -- Parsing
289289
do
290290
create txt.make (64)
291291
request_header := txt
292-
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
292+
if
293+
not has_error and then
294+
a_socket.is_readable and then
295+
attached next_line (a_socket) as l_request_line and then
296+
not l_request_line.is_empty
297+
then
293298
txt.append (l_request_line)
294299
txt.append_character ('%N')
295300
analyze_request_line (l_request_line)
@@ -302,7 +307,7 @@ feature -- Parsing
302307
from
303308
line := next_line (a_socket)
304309
until
305-
line = Void or end_of_stream
310+
line = Void or end_of_stream or has_error
306311
loop
307312
n := line.count
308313
if l_is_verbose then
@@ -372,15 +377,31 @@ feature -- Parsing
372377
next_line (a_socket: HTTPD_STREAM_SOCKET): detachable STRING
373378
-- Next line fetched from `a_socket' is available.
374379
require
380+
not_has_error: not has_error
375381
is_readable: a_socket.is_open_read
376382
local
377383
retried: BOOLEAN
378384
do
379385
if retried then
386+
has_error := True
380387
Result := Void
381-
elseif a_socket.socket_ok then
388+
elseif a_socket.readable then
382389
a_socket.read_line_thread_aware
383390
Result := a_socket.last_string
391+
-- Do no check `socket_ok' before socket operation,
392+
-- otherwise it may be False, due to error during other socket operation in same thread.
393+
if not a_socket.socket_ok then
394+
has_error := True
395+
if is_verbose then
396+
log ("%N## Socket is not ok! ##")
397+
end
398+
end
399+
else
400+
-- Error with socket...
401+
has_error := True
402+
if is_verbose then
403+
log ("%N## Socket is not readable! ##")
404+
end
384405
end
385406
rescue
386407
retried := True

0 commit comments

Comments
 (0)