Socket Deadlock

vek on 2002-05-16T22:40:58

Yippee - I got to work on some Perl code today. Unfortunately it was a bug report with the ever helpful description of "well it just hangs and doesn't return anything to the screen".

I suspected the socket code might be to blame. The program in question is one of our Credit Card daemon's. So I asked if the remote client had been modified (it had) so then I asked if the client socket code had been modified (it had). So I get to this snippet of code in our daemon and just sighed:

while (<$sock>)

No, please don't do that. It's no wonder you're in I/O blocking hell. So a quick rewrite with IO::Select and sysread fixed things up nicely.