Author: richter Date: Tue Oct 28 07:05:17 2014 New Revision: 1634801 URL: http://svn.apache.org/r1634801 Log: Make Embperl Coro Thread Safe
Modified: perl/embperl/trunk/Embperl.pm Modified: perl/embperl/trunk/Embperl.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl.pm?rev=1634801&r1=1634800&r2=1634801&view=diff ============================================================================== --- perl/embperl/trunk/Embperl.pm (original) +++ perl/embperl/trunk/Embperl.pm Tue Oct 28 07:05:17 2014 @@ -128,7 +128,7 @@ sub Execute local $SIG{__WARN__} = \&Warn ; # when called inside a Embperl Request, Execute the component only - return Embperl::Req::ExecuteComponent ($_ep_param, @_) if ($req) ; + return Embperl::Req::ExecuteComponent ($_ep_param, @_) if ($req && $Embperl::coro_req == $Coro::current) ; $_ep_param = { inputfile => $_ep_param, param => [@_]} if (!ref $_ep_param) ; @@ -152,11 +152,21 @@ sub Execute $req_rec = $_ep_param -> {req_rec} ; } + + my $eplguard ; + if (defined ($Coro::current)) + { + # make sure that there is only one request at the same time + $Embperl::coro_semaphore ||= Coro::Semaphore -> new (1) ; + $eplguard = $Embperl::coro_semaphore -> guard ; + $Embperl::coro_req = $Coro::current ; + } my $_ep_rc ; { $_ep_rc = Embperl::Req::ExecuteRequest (undef, $_ep_param) ; } - + undef $eplguard ; + return $_ep_rc ; } --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-cvs-unsubscr...@perl.apache.org For additional commands, e-mail: embperl-cvs-h...@perl.apache.org