Subject: | NetSend gets stuck |
Date: | Wed, 8 Jan 2014 08:45:20 -0500 |
To: | <bug-Win32-NetSend [...] rt.cpan.org> |
From: | "Tom Bates" <tom [...] tombates.net> |
I have a script that runs nightly to check various directories for number of files and total storage. Upon completion, I use NetSend to send a message to a given computer.
Occasionally, perl crashes, and I’ve found this is because the script gets stuck and the nightly job gets terminated forcefully by Windows XP.
In running the script from the command line, I’ve reproduced the issue. Rebooting the machine cures the problem for a long while, so I suspect is has to do with resources. However, no error messages are generated and interactive programs all seem to work fine.
I’ve narrowed down the code to this section within the function send_single_block_message():
#####################################
# Receive & Check Answer #
#####################################
my $init_resp="";
my $answer_received=0;
my $inmask = '';
vec($inmask, fileno($sock), 1) = 1;
while (select(my $outmask = $inmask, undef, undef, 0.4)) {
recv($sock, $init_resp, 1024, 0);
$answer_received = 1;
}
This code continually loops without end and without a perceptible pause, receiving 0 bytes each time. I believe some kind of error is occurring below this level and is not being detected.
I tried manually executing the recv in the debugger, and got this:
DB<3> $ppp=recv($sock, $init_resp, 1024, 0)
DB<4> x $ppp
0 "\cB\c@\c@ï└¿8\cA\c@\c@\c@\c@\c@\c@\c@\c@"
I’m not familiar with socket programming in Perl so I’m not sure if this can provide any useful information.
If you’d like me to try something, I can give it a shot.
Thanks
Tom