1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00

Prevent potential infinite loop.

This may be part of the problem in #103, but I am not sure. I will try
it and see if the issue reoccurs.

Closes #103.
This commit is contained in:
Jon Leighton 2012-07-10 23:46:35 +01:00
parent d9233c2d89
commit 122bb67b21

View file

@ -125,7 +125,10 @@ module Capybara::Poltergeist
# Block until the next message is available from the Web Socket.
# Raises Errno::EWOULDBLOCK if timeout is reached.
def receive
start = Time.now
until handler.message?
raise Errno::EWOULDBLOCK if (Time.now - start) >= timeout
IO.select([socket], [], [], timeout) or raise Errno::EWOULDBLOCK
data = socket.recv(RECV_SIZE)
break if data.empty?