Fix for the Webrick "Errno::EINVAL: Invalid argument" error

Y

Yura Kloubakov

It turns out that the problem is with the following HTTPServer#run code:

while timeout > 0
break if IO.select([sock], nil, nil, 0.5)
timeout = 0 if @status != :Running
timeout -= 0.5
end
raise HTTPStatus::EOFError if timeout <= 0
req.parse(sock)

where parse(sock) throws StandardError exception.
It happens because IO.select returns [[sock], [], []] while client has
closed its side of the connection. The fix can be as simple as adding
test for the sock.eof to the raise statement:

raise HTTPStatus::EOFError if timeout <= 0 || sock.eof?

Or may be it should be:

break if timeout <= 0 || sock.eof?

Regards,
Yura.
 
G

GOTOU Yuuzou

Hi,

In message said:
It happens because IO.select returns [[sock], [], []] while client has
closed its side of the connection. The fix can be as simple as adding
test for the sock.eof to the raise statement:

raise HTTPStatus::EOFError if timeout <= 0 || sock.eof?

Thanks. Should I apply it to Ruby 1.9 too?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top