[Spread-users] selecting on spread file descriptor

Kevin Kamel kamelkev at gmail.com
Tue Jan 25 17:33:32 EST 2005


Hi,

     Please bear with me because I'm a perl guy, but the general
concepts here everybody is probably familiar with.

     I'm looking to use spread to handle manage workers. I'm actually
forking off workers to handle work as it comes in (I am aware of the
spread fork issues and have been using SP_kill, through perl...).

    For the message handling I basically do what follows here, but for
whatever reason I notice 3 successive iterations in the while loop for
each message. I very consistently notice that for 2 of the 3 passes
can_read gives a handle, poll returns true and receive is called...
but the message never makes it to my message handler. Why? Are these
control messages that are not intended for end users? If so why does
poll return true for them?

code: 

$selector = new IO::Select($spread->{MAILBOX});

while (my @ready = $selector->can_read($sleeptime)) {
    #sleep timed out 
    if(scalar(@ready) == 0) {
       print "timed out\n";
    }
    #we received a message
    else {
       print "received a message\n";
       foreach my $handle(@ready) {
          #poll to see if the message was actually received
          if ($spread->poll()) {
            $spread->receive();
	    print "received a message\n";
          }
       } #end foreach handle
    } #else
} #while loop


Thanks for taking a look, any suggestions are appreciated.

-Kevin




More information about the Spread-users mailing list