Loading ...
Sorry, an error occurred while loading the content.

4815Objects, Threads and Mod_Perl Woes [long]

Expand Messages
  • jamethiel_w
    Jul 27, 2005
      Hi There,

      I don't know if this is the right forum, but, I have a number of
      SOAP::Lite clients who eventually execute "handleCall". I have a
      simple mod_perl dispatcher:

      package SOAP::Apache;

      use lib "/usr/local/soap";
      use SOAP::Transport::HTTP;

      my $server=SOAP::Transport::HTTP::Apache

      sub handler { $server->handler(@_) }

      Now, I instantiate a significant number of objects in ybCall and I had
      a lot of problems with threading. I think I still have problems with
      mod_perl persistence, objects and constructors simply not being called
      at all.

      Here is my invoker (handleCall):

      sub handleCall {
      my $self=shift;

      my $result="ERROR: Unknown object!";

      # Here we start the thread. We need to run in a thread because
      of the way
      # mod_perl runs.
      my $myThread=Thread->new(\&handleObject, \@_);

      # Now we wait to collect the result
      eval {

      if ($@) {
      return "ERROR: $@";
      } else {

      Notice the first thing I do is create a new thread. Eventually,
      handleObject does things like:

      SWITCH: {
      # CONFIRM #
      ($instruction eq "confirm") && do {

      if ($tokenObject) {

      } else {
      $result="Failed to instantiate object
      to commence the confirmation of the token!";
      last SWITCH;

      The point is I grab the params, and send the parameters to the
      objects' constructors.

      Here's where I get in trouble.

      I put 6 different clients all at once using this. The system behaved
      as though it were constructing random objects, however on closer
      inspection I think mod_perl IS NOT reinitialising my blessed objects
      with the new parameters (that is to say, it's as though something is
      saying: aha! I've got a YB::STOCK::ybToken object and I'm gonna use that).

      Another piece to the puzzle: I threw my hands in the air in disgust
      and created a CGI dispatcher - figuring that slow is better than not
      working at all. Unsurprisingly, this dispatcher functions correctly.

      So here are my questions:

      1. In my setup, even though I create a thread (and threads don't
      share data according to perldoc Thread) at the earliest possible
      stage, why are my objects seemingly not being initialised?

      2. Alternatively, let's say one Apache process gets 3 threads. (A, B
      and C). A description of the problem is that 'under some
      circumstances, B might get A's response, C might get B's response AND
      it's seeming random'?

      3. When I force a recompile (using old-fashioned CGI), how come it
      suddenly works?

      4. Is this a SOAP::Lite question or a mod_perl question? Am I
      providing sufficient information?

      I'm rather confused though slightly pleased I may have found an answer.