Forum: Ruby how to build a daemon

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dominik Werder (Guest)
on 2006-03-29 13:34
(Received via mailing list)
Hello!

While building a little network daemon I stumbled upon the following
issue:

I have no idea how much data I can read without blocking. So an attacker
could simply ignore the protocol and stop the transfer so that my daemon
blocks forever..
How do you avoid this simple issue? The only method I found is setting a
Timeout::timeout 10 do end  around the code, but this requires the
timeout module and I don't know if this works reliable..

Could anybody please give me a hint? Thank you!

bye!
Dominik
Robert K. (Guest)
on 2006-03-29 13:54
(Received via mailing list)
Dominik Werder wrote:
> Hello!
>
> While building a little network daemon I stumbled upon the following issue:
>
> I have no idea how much data I can read without blocking. So an attacker
> could simply ignore the protocol and stop the transfer so that my daemon
> blocks forever..
> How do you avoid this simple issue? The only method I found is setting a
> Timeout::timeout 10 do end  around the code, but this requires the
> timeout module and I don't know if this works reliable..

You'd typically have a thread that handles a connection.  So the worst
case is that a single thread blocks om IO but this does not block the
whole process.  You're only out of luck if Ruby is stuck in some long
running call into an external C lib (can be a system call or whatever)
because it doesn't support native threads (yet).

Kind regards

	robert
This topic is locked and can not be replied to.