DRb hanging/blocking on access to /proc filesystem


D

David Felstead

Hi all,

The following code causes ruby to hang on Linux CentOS 4 (tested on
1.8.2, 1.8.3, 1.8.4 and 1.9 HEAD as of last night):

====
#!/usr/bin/env ruby
require 'drb'

# This works fine
File.read('/proc/loadavg')

# Start the DRb server thread
DRb.start_service

# This works fine - accessing normal file
File.read('/etc/passwd')

# This call causes the program to hang
File.read('/proc/loadavg')
===

It seems that attempting to access anything in the /proc filesystem
causes DRb to block on a select call, as evident in this strace:

<strace snip>
open("/proc/loadavg", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7d32000
_llseek(4, 0, [0], SEEK_CUR) = 0
select(5, [3 4], [], [], NULL

The fd's that select is waiting on are these:
lrwx------ 1 dfelstead dfelstead 64 Feb 18 20:18 3 -> socket:[1130388]
lr-x------ 1 dfelstead dfelstead 64 Feb 18 20:18 4 -> /proc/loadavg

This happens regardless of the way that DRb is opened, whether or not
it is in a separate thread or not, etc. I've also had it happen when
accessing other, normal fs files, (it blocks on an 'accept' call in
that case) but I haven't been able to reproduce it relaibly. This
example fails every time for me.

Any ideas?

Cheers!

-David Felstead
 
Ad

Advertisements

T

Tanaka Akira

David Felstead said:
The following code causes ruby to hang on Linux CentOS 4 (tested on
1.8.2, 1.8.3, 1.8.4 and 1.9 HEAD as of last night):
# This call causes the program to hang
File.read('/proc/loadavg')

It seems like the problem before Linux 2.6.13.
See [ruby-talk:155745].
 

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

Top