This repository has been archived by the owner. It is now read-only.

Fixed timeouts in Net::Ping::External #32

Merged
merged 2 commits into from Mar 27, 2014

Conversation

Projects
None yet
3 participants
Contributor

bcandrea commented Mar 26, 2014

Using Timeout.timeout with Open3 is not an option with Ruby > 1.9.3
(see https://bugs.ruby-lang.org/issues/5487). Implemented a workaround
based on the code at https://gist.github.com/lpar/1032297

Fixed timeouts in Net::Ping::External
Using Timeout.timeout with Open3 is not an option with Ruby > 1.9.3
(see https://bugs.ruby-lang.org/issues/5487). Implemented a workaround
based on the code at https://gist.github.com/lpar/1032297

Eesh, ok. Good work.

Can you confirm that the code works and the tests pass with JRuby, too?

Update travis.yml to trigger CI run
This update should trigger a Travis CI build on different Rubies.
Contributor

bcandrea commented Mar 26, 2014

Yes, Travis looks reasonably happy. I also ran this simple test on my local Rubies (2.0.0, 2.1.0, 2.1.1 and JRuby 1.7.9):

#!/usr/bin/env ruby
# net-ping/test.rb
$LOAD_PATH.unshift 'lib'
require 'net/ping'
require 'benchmark'

p = Net::Ping::External.new '10.0.0.0'
p.timeout = 1
Benchmark.bm do |x|
  x.report { p.ping }
end

The results for JRuby are:

$ rbenv shell jruby-1.7.9 
$ ruby -v
jruby 1.7.9 (1.9.3p392) 2013-12-06 87b108a on OpenJDK 64-Bit Server VM 1.7.0_51-b00 [linux-amd64]
aleph@eve:~/projects/net-ping$ ./test_ping.rb 
       user     system      total        real
   0.830000   0.620000   1.450000 (  1.017000)

djberg96 added a commit that referenced this pull request Mar 27, 2014

Merge pull request #32 from bcandrea/develop
Fixed timeouts in Net::Ping::External

@djberg96 djberg96 merged commit 61cd0a4 into djberg96:master Mar 27, 2014

1 check passed

default The Travis CI build passed
Details
Owner

djberg96 commented Mar 27, 2014

Hm, it seems Windows is very unhappy. This is why Travis CI really needs cross platform support. I'll see if I can fix it, but I may have to undo this.

Owner

djberg96 commented Mar 27, 2014

It looks like Windows doesn't like read_nonblock. Replacing it with a standard read worked. At least, the tests all passed.

Contributor

bcandrea commented Mar 27, 2014

Sorry, my fault (I don't have access to a full-featured Windows test machine unfortunately). The select call on pipes is indeed unsupported on Windows. However, are you sure that the standard read does the job? I tried it quickly and it seems to wait until the ping subprocess exits... and additionally my Process.kill("TERM", pid) fails with Errno::EINVAL on Windows, so I had to switch to Process.kill("KILL", pid), which looks a bit more drastic.

Disclaimer: as I said, my win32 test platform is quite limited (MRI 2.0.0 only). I can spend some more time on this later maybe.

Owner

djberg96 commented Mar 27, 2014

I ran rake test:external and all tests passed with both mingw (32 and 64 bit versions) and a version built using Visual Studio.

Owner

djberg96 commented Mar 27, 2014

That's on Windows 7, btw. Are the tests failing for you?

Contributor

ianheggie commented Mar 28, 2014

Pik might be of use for multiple ruby versions under windows. Now just need a os/x test machine ... ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.