Tony Arcieri <tony at medioh.com> wrote:> I am preparing to release rev 0.3.0 with the following changes:
> - Added Rev::Listener#fileno for accessing the underlying file descriptor
>
> - Support for creating Rev::Listeners from existing TCPServers/UNIXServers
Cool. I''ve just pushed out similar changes to Rev::Server that I may
need in the near future:
Eric Wong (2):
Rev::UNIXServer: use path instead of the first argument
Rev::Server-based classes can build off ::*Server objects
lib/rev/server.rb | 21 ++++++++++++++++++---
spec/unix_server_spec.rb | 25 +++++++++++++++++++++++++
2 files changed, 43 insertions(+), 3 deletions(-)
Pullable from git://yhbt.net/rev.git
(browsable from http://git.bogomips.org/cgit/rev.git, too)
> - Upgrade to libev 3.8
> - Uses iobuffer gem instead of its own Rev::Buffer class. This gem is now
> optimized so it no longer makes any system calls aside from read/write,
> whereas the previous one needlessly polled for the current time in many
> cases (as part of its memory pooling).
I just tried installing iobuffer under 1.8.7 and got this:
cc -I. -I. -I/home/ew/lib/ruby/1.8/x86_64-linux -I. -fPIC -pipe -Wall -O2
-momit-leaf-frame-pointer -c iobuffer.c
iobuffer.c: In function ?IO_Buffer_read_from?:
iobuffer.c:292: error: ?rb_io_t? has no member named ?fd?
iobuffer.c: In function ?IO_Buffer_write_to?:
iobuffer.c:315: error: ?rb_io_t? has no member named ?fd?
make: *** [iobuffer.o] Error 1
It installs fine under 1.8.6 and 1.9.1. Unfortunately many people got
switched to 1.8.7 by their vendor... Not sure if you care.
> As you may or may not know, Rev''s test suite is virtually
nonexistent :( :(
> :(. If you are using Rev, I''d love for you to test out HEAD off
github and
> let me know if it works for you:
I need to get around to working on projects that use Rev :)
Those will eventually have fairly complete (though probably strange)
integration tests. I''m not a huge fan of unit tests (especially not of
mocking), for network servers/clients. I''d rather just fire up a whole
server/client combo.
Taking TCP ports and expecting them to run right all the time can be a
pain as well as well. I''ve been using the following bit for some
projects I''ve been working on:
----------------------------- 8< --------------------------
# unused_port provides an unused port on +addr+ usable for TCP that is
# guaranteed to be unused across all xxxxxx builds on that system. It
# prevents race conditions by using a lock file other xxxxxx builds
# will see. This is required if you perform several builds in parallel
# with a continuous integration system or run tests in parallel via
# gmake. This is NOT guaranteed to be race-free if you run other
# processes that bind to random ports for testing (but the window
# for a race condition is very small). You may also set XXXXXX_TEST_ADDR
# to override the default test address (127.0.0.1).
def unused_port(addr = ''127.0.0.1'')
retries = 100
base = 5000
port = sock = nil
begin
begin
port = base + rand(32768 - base)
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
sock.bind(Socket.pack_sockaddr_in(port, addr))
sock.listen(5)
rescue Errno::EADDRINUSE, Errno::EACCES
sock.close rescue nil
retry if (retries -= 1) >= 0
end
# since we''ll end up closing the random port we just got,
there''s a race
# condition could allow the random port we just chose to reselect itself
# when running tests in parallel with gmake. Create a lock file while
# we have the port here to ensure that does not happen .
lock_path = "#{Dir::tmpdir}/xxxxxx_test.#{addr}:#{port}.lock"
lock = File.open(lock_path, File::WRONLY|File::CREAT|File::EXCL, 0600)
at_exit { File.unlink(lock_path) rescue nil }
rescue Errno::EEXIST
sock.close rescue nil
retry
end
sock.close rescue nil
port
end
----------------------------- 8< --------------------------
I should probably take out the project-specific "xxxxxx_" prefix here:
lock_path = "#{Dir::tmpdir}/test.#{addr}:#{port}.lock"
Or even spinning that into its own gem since I expect to have more
projects using it...
> git://github.com/tarcieri/rev.git
>
> You will need to "rake gem" in order to build the gem. After
that you can
> install it.
I had to manually build README to get "rake gem" to work via
"cp README.textile README"
--
Eric Wong