I've done a little more digging and now I'm really confused.

Consider the following '_stop' handler for a Client::Ping session.

  sub handler_stop {
    print "Session ", $_[SESSION]->ID, " has stopped.\n";
    print $poe_kernel->get_active_event() . " - " .
$poe_kernel->get_event_count() . "\n";
    #$poe_kernel->stop();
  }
---------------------------------
When I bring my own socket, this happens on call of '_stop'

Session 3 has stopped.
_stop - 0

(app spins)

-------------------------------

Shouldn't kernel->run return based on the following comment?

  # Run the event loop, only returning when it has no more sessions to
  # dispatch events to.  Supports two forms.
  $poe_kernel->run();

--------------------------------

If I add the kernel->stop(), my app 'seems' to work [as root; haven't
messed with setuid yet].  I'd say 95% of the time, get_event_count
returns 0 in the _stop handler, but sometimes it returns a positive
integer; how could the _stop handler be called if the get_event_count is
non zero, though?

"_stop is sent to a session when it's about to stop. This usually occurs
when a session has run out of events to handle and resources to generate
new events."

Also, POE::Kernel docs say

"stop() has been added as an experimental function to support forking
child kernels with POE::Wheel::Run. We may remove it without notice if
it becomes really icky. If you have good uses for it, please mention
them on POE's mailing list."

So I don't want to become dependent on a feature that is hacking around
a real problem or may disappear!

-Michael

Michael Hare wrote:
> Hello-
> 
> Firstly, I want to thank all of the responses I've received thus far.
> I'm still learning system level programming so some of these ideas are
> at first foreign.
> 
> I'm having problems understanding how to use the 'bring your own socket'
> feature of Client::Ping.  I'm investigating using my own sockets so that
> I can open a socket as root and then setuid to the desired user.
> 
> If I take working code where Client::Ping provides the socket and then
> just change it so that I provide the socket (and stay the root user
> even), after everything is 'done', $poe_kernel->run() never exits.  If I
> enable DEBUG I see unrelated packets coming after all of my expected
> testing is done.  I included a '_stop' handler and that -is- getting run.
> 
> Is this problem because there is still a socket open?  If so, is there a
> way to deal with this?  Closing the socket would not be ideal because I
> explicitly opened the socket as root and setuid to my desired 'utility'
> user in the begging on the program.  My goal is to be able to run the
> poller in a loop so it would be nice to reuse the socket after a
> successful completion of $poe_kernel->run();
> 
> I can post the code I'm using if that helps.  Sorry if this is a rather
> basic question.
> 
> Thanks-
> -Michael
> 

Reply via email to