[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to build a daemon

Dominik Werder

3/29/2006 9:32:00 AM

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
1 Answer

Robert Klemme

3/29/2006 9:51:00 AM

0

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