[Fwd: Conflicting mod_perl 2 documentation -- no print() method in Apache2::RequestRec]

2011-11-14 Thread David Booth
Stas Bekman suggested that I forward this issue to this list . . . .

 Forwarded Message 
From: David Booth 

This section of the mod_perl 2 User Guide:
http://perl.apache.org/docs/2.0/user/handlers/intro.html#What_are_Handlers_
shows a simple handler subroutine that will be called with an
Apache2::RequestRec object $r.  It includes the following statement that
calls a print() method:
[[
  $r->print("Now is: " . scalar(localtime) . "\n");
]]
But there is no print() method defined in Apache2::RequestRec, and there
is no indication that Apache2::RequestRec inherits from any other class:
http://search.cpan.org/~phred/mod_perl-2.0.5/docs/api/Apache2/RequestRec.pod

After wasting a couple of hours trying to figure this out, I noticed in
http://search.cpan.org/~phred/mod_perl-2.0.5/docs/api/Apache2/RequestRec.pod#output_filters
a bad link from "$r->print()" to
http://search.cpan.org/perldoc?docs%3A%3A2.0%3A%3Aapi%3A%3AApache2%3A%3ARequestIO#C_print_
which attempted to point to the Apache2::RequestIO documentation, and
that documentation does indeed list a print() method:
http://perl.apache.org/docs/2.0/api/Apache2/RequestIO.html#C_print_

Since Apache2::RequestIO extends Apache2::RequestRec, this seems to
suggest that the handler is actually called with an Apache2::RequestIO
object -- *not* merely an Apache2::RequestRec object.

If this is indeed correct, it would be very helpful if the documentation
at
http://perl.apache.org/docs/2.0/user/handlers/intro.html
were updated with this correction.

Thanks!


-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: PIPE and mod_perl2

2011-12-05 Thread David Booth
On Mon, 2011-12-05 at 17:39 +0400, Denis Spichkin wrote:
[ . . . ]
> so now I need find out how generate page with out Content-Length in mod_perl

I believe you need to force Apache to flush the headers.  Otherwise it
will try to compute and add the Content-Length header for you.  See
http://perl.apache.org/docs/2.0/user/handlers/http.html#item_The_special_case_of__code_Content_Length__0__code_


-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



How to run shell command from response handler? (Apache2 child segmentation fault)

2012-01-03 Thread David Booth
I am trying to run a shell command from a mod_perl2 response handler.
It works properly for some number of HTTP requests, but sometimes it
fails (somewhat randomly) and I see in my Apache2 error log that one of
the Apache2 child processes has died with a segmentation fault.  
For example, /var/log/apache2/error.log shows:

[Tue Jan 03 12:16:10 2012] [notice] child pid 3538 exit signal Segmentation 
fault (11)

Is this normal?  How does one normally run a shell command from a
response handler?  I do not want to return the command's output to the
client.

Here is a trivial example response handler that exhibits this behavior:

sub handler
{
my $r = shift || die;
my $f = $ENV{DOCUMENT_ROOT} . "/date.txt";
system("date >> $f");
$r->internal_redirect("/date.txt");
return Apache2::Const::OK;
}

Can anyone provide any guidance?  Does this work for you?  

Note that you may not notice the problem if you don't carefully watch
the Apache2 error log (e.g., with "tail -f /var/log/apache2/error.log"),
because Apache2 automatically spawns new children processes as needed,
and client (such as Firefox or wget, though not curl) seem to
automatically re-try the request when it fails, thus giving the illusion
of succeeding.  

P.S. I have posted about this on perlmonks, but thus far have not found
a solution:
http://www.perlmonks.org/?node_id=945947


-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: How to run shell command from response handler? (Apache2 child segmentation fault)

2012-01-03 Thread David Booth
I tried redirecting stderr to /dev/null and it did not help:
system("date >> $f 2> /dev/null");

I am using the worker processing model.  Does it work for you (or anyone
else) without causing periodic child process segmentation faults?


On Tue, 2012-01-03 at 16:29 -0500, Daniel Risacher wrote:
> It's been a while since I looked at doing this, but IIRC it's fairly
> dependent on the processing model that Apache is using.  Are you
> mpm_prefork, or mpm_worker?
> 
> Also, I found it was important to redirect stderr to /dev/null:
> 
> sub play {
> system "/usr/bin/xmms -t 2> /dev/null";
> }
> 
> 
> On Tue, Jan 3, 2012 at 12:48 PM, David Booth  wrote:
> > I am trying to run a shell command from a mod_perl2 response handler.
> > It works properly for some number of HTTP requests, but sometimes it
> > fails (somewhat randomly) and I see in my Apache2 error log that one of
> > the Apache2 child processes has died with a segmentation fault.
> > For example, /var/log/apache2/error.log shows:
> >
> > [Tue Jan 03 12:16:10 2012] [notice] child pid 3538 exit signal Segmentation 
> > fault (11)
> >
> > Is this normal?  How does one normally run a shell command from a
> > response handler?  I do not want to return the command's output to the
> > client.
> >
> > Here is a trivial example response handler that exhibits this behavior:
> >
> > sub handler
> > {
> > my $r = shift || die;
> > my $f = $ENV{DOCUMENT_ROOT} . "/date.txt";
> > system("date >> $f");
> > $r->internal_redirect("/date.txt");
> > return Apache2::Const::OK;
> > }
> >
> > Can anyone provide any guidance?  Does this work for you?
> >
> > Note that you may not notice the problem if you don't carefully watch
> > the Apache2 error log (e.g., with "tail -f /var/log/apache2/error.log"),
> > because Apache2 automatically spawns new children processes as needed,
> > and client (such as Firefox or wget, though not curl) seem to
> > automatically re-try the request when it fails, thus giving the illusion
> > of succeeding.
> >
> > P.S. I have posted about this on perlmonks, but thus far have not found
> > a solution:
> > http://www.perlmonks.org/?node_id=945947
> >
> >
> > --
> > David Booth, Ph.D.
> > http://dbooth.org/
> >
> > Opinions expressed herein are those of the author and do not necessarily
> > reflect those of his employer.
> >
> 
> 

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



[SOLVED] Re: How to run shell command from response handler? (Apache2 child segmentation fault)

2012-01-03 Thread David Booth
Thanks for the suggestion.  I tried it with prefork and the problem
still occurred.  HOWEVER, I then decided to remove all modules down to a
minimal example, and discovered that the mere inclusion of the following
module:

  use Test::MockObject;

was causing the segmentation fault after several successful requests,
even though no functions whatsoever were called.  Since this appears to
be a bug in Test::MockObject, I reported the bug here:
https://rt.cpan.org/Public/Bug/Display.html?id=73723

The bug report shows the exact minimal handler code that I used to
reproduce the bug.

Best wishes,
David


On Tue, 2012-01-03 at 17:26 -0500, Daniel Risacher wrote:
> I think I've been bitten by this too, years ago.
> 
> I *think* I solved it by switching to mpm_prefork, which was
> unsatisfying, but adequate for my needs.
> 
> On Tue, Jan 3, 2012 at 5:21 PM, David Booth  wrote:
> > I tried redirecting stderr to /dev/null and it did not help:
> > system("date >> $f 2> /dev/null");
> >
> > I am using the worker processing model.  Does it work for you (or anyone
> > else) without causing periodic child process segmentation faults?
> >
> >
> > On Tue, 2012-01-03 at 16:29 -0500, Daniel Risacher wrote:
> >> It's been a while since I looked at doing this, but IIRC it's fairly
> >> dependent on the processing model that Apache is using.  Are you
> >> mpm_prefork, or mpm_worker?
> >>
> >> Also, I found it was important to redirect stderr to /dev/null:
> >>
> >> sub play {
> >> system "/usr/bin/xmms -t 2> /dev/null";
> >> }
> >>
> >>
> >> On Tue, Jan 3, 2012 at 12:48 PM, David Booth  wrote:
> >> > I am trying to run a shell command from a mod_perl2 response handler.
> >> > It works properly for some number of HTTP requests, but sometimes it
> >> > fails (somewhat randomly) and I see in my Apache2 error log that one of
> >> > the Apache2 child processes has died with a segmentation fault.
> >> > For example, /var/log/apache2/error.log shows:
> >> >
> >> > [Tue Jan 03 12:16:10 2012] [notice] child pid 3538 exit signal 
> >> > Segmentation fault (11)
> >> >
> >> > Is this normal?  How does one normally run a shell command from a
> >> > response handler?  I do not want to return the command's output to the
> >> > client.
> >> >
> >> > Here is a trivial example response handler that exhibits this behavior:
> >> >
> >> > sub handler
> >> > {
> >> > my $r = shift || die;
> >> > my $f = $ENV{DOCUMENT_ROOT} . "/date.txt";
> >> > system("date >> $f");
> >> > $r->internal_redirect("/date.txt");
> >> > return Apache2::Const::OK;
> >> > }
> >> >
> >> > Can anyone provide any guidance?  Does this work for you?
> >> >
> >> > Note that you may not notice the problem if you don't carefully watch
> >> > the Apache2 error log (e.g., with "tail -f /var/log/apache2/error.log"),
> >> > because Apache2 automatically spawns new children processes as needed,
> >> > and client (such as Firefox or wget, though not curl) seem to
> >> > automatically re-try the request when it fails, thus giving the illusion
> >> > of succeeding.
> >> >
> >> > P.S. I have posted about this on perlmonks, but thus far have not found
> >> > a solution:
> >> > http://www.perlmonks.org/?node_id=945947
> >> >
> >> >
> >> > --
> >> > David Booth, Ph.D.
> >> > http://dbooth.org/
> >> >
> >> > Opinions expressed herein are those of the author and do not necessarily
> >> > reflect those of his employer.
> >> >
> >>
> >>
> >
> > --
> > David Booth, Ph.D.
> > http://dbooth.org/
> >
> > Opinions expressed herein are those of the author and do not necessarily
> > reflect those of his employer.
> >
> 
> 

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: [SOLVED] Re: How to run shell command from response handler? (Apache2 child segmentation fault)

2012-01-08 Thread David Booth
Hi Jon,

My code actually needed to run other shell commands.  I just used the
`date` function as a simple example to demonstrate the problem.  

David

On Sat, 2012-01-07 at 02:44 -0700, Jon wrote:
> Hello All,
> 
> 
> Ok, maybe I'm missing the whole point of this thread, but why is this
> solution better than using the built-in perl `date` function?
> 
> 
> Personally, I think using the system 'date' function provides too many
> variables [read: problems] when attempting cross-platform continuity.
>  
> 
> 
> Maybe I have misunderstood the whole point of this thread, but it
> seems to me that everyone is over-engineering the problem... (i've
> only been a Perl programmer for like three years, so I still have
> ton's to learn... hopefully I can learn from this if I'm  way off
> base)
> 
> 
> Thanks,
> Jon A
> 
> On Tue, Jan 3, 2012 at 8:38 PM, David Booth  wrote:
> Thanks for the suggestion.  I tried it with prefork and the
> problem
> still occurred.  HOWEVER, I then decided to remove all modules
> down to a
> minimal example, and discovered that the mere inclusion of the
> following
> module:
> 
>  use Test::MockObject;
> 
> was causing the segmentation fault after several successful
> requests,
> even though no functions whatsoever were called.  Since this
> appears to
> be a bug in Test::MockObject, I reported the bug here:
> https://rt.cpan.org/Public/Bug/Display.html?id=73723
> 
> The bug report shows the exact minimal handler code that I
> used to
> reproduce the bug.
> 
> Best wishes,
> David
> 
> 
> On Tue, 2012-01-03 at 17:26 -0500, Daniel Risacher wrote:
> > I think I've been bitten by this too, years ago.
>     >
> > I *think* I solved it by switching to mpm_prefork, which was
> > unsatisfying, but adequate for my needs.
> >
> > On Tue, Jan 3, 2012 at 5:21 PM, David Booth
>  wrote:
> > > I tried redirecting stderr to /dev/null and it did not
> help:
> > > system("date >> $f 2> /dev/null");
> > >
> > > I am using the worker processing model.  Does it work for
> you (or anyone
> > > else) without causing periodic child process segmentation
> faults?
> > >
> > >
> > > On Tue, 2012-01-03 at 16:29 -0500, Daniel Risacher wrote:
> > >> It's been a while since I looked at doing this, but IIRC
> it's fairly
> > >> dependent on the processing model that Apache is using.
>  Are you
> > >> mpm_prefork, or mpm_worker?
> > >>
> > >> Also, I found it was important to redirect stderr
> to /dev/null:
> > >>
> > >> sub play {
> > >> system "/usr/bin/xmms -t 2> /dev/null";
> > >> }
> > >>
> > >>
> > >> On Tue, Jan 3, 2012 at 12:48 PM, David Booth
>  wrote:
> > >> > I am trying to run a shell command from a mod_perl2
> response handler.
> > >> > It works properly for some number of HTTP requests, but
> sometimes it
> > >> > fails (somewhat randomly) and I see in my Apache2 error
> log that one of
> > >> > the Apache2 child processes has died with a
> segmentation fault.
> > >> > For example, /var/log/apache2/error.log shows:
> > >> >
> > >> > [Tue Jan 03 12:16:10 2012] [notice] child pid 3538 exit
> signal Segmentation fault (11)
> > >> >
> > >> > Is this normal?  How does one normally run a shell
> command from a
> > >> > response handler?  I do not want to return the
> command's output to the
> > >> > client.
> > >> >
> > >> > Here is a trivial example response handler that
> exhibits this behavior:
> > >> >
> > >> > sub handler
> > >> > {
> > >> > my $r = shift || die;
> > >> > my $f = $ENV{DOCUMENT_ROOT} . "/date.txt";
> > >

Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread David Booth
On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
> I have a PerlResponseHandler which processes some kind of "logical 
> document-id" provided 
> in a request, locates the corresponding "real document" on the filesystem, 
> and returns it 
> to the client via sendfile().
> At the moment, this handler uses its own custom logic to determine the MIME 
> type of the 
> document and return it to the client as a Content-type HTTP header.
> 
> My question is : instead of this custom logic, does there exist a way, via 
> mod_perl, to 
> obtain this target file's MIME-type from Apache, using Apache's own logic 
> (mod_mime, 
> AddType etc..) for that ?

This isn't exactly what you asked for, but if you don't need to server
anything else along with it, then perhaps you could use
internal_redirect
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_
and let Apache set the Content-Type for you.  

If you do find the direct answer to your question, please post it, as
I'm interested in this question also.

Thanks!

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread David Booth
On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:
> On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
> > I have a PerlResponseHandler which processes some kind of "logical 
> > document-id" provided 
> > in a request, locates the corresponding "real document" on the filesystem, 
> > and returns it 
> > to the client via sendfile().
> > At the moment, this handler uses its own custom logic to determine the MIME 
> > type of the 
> > document and return it to the client as a Content-type HTTP header.
> > 
> > My question is : instead of this custom logic, does there exist a way, via 
> > mod_perl, to 
> > obtain this target file's MIME-type from Apache, using Apache's own logic 
> > (mod_mime, 
> > AddType etc..) for that ?
> 
> This isn't exactly what you asked for, but if you don't need to server
> anything else along with it, then perhaps you could use
> internal_redirect
> http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_
> and let Apache set the Content-Type for you.  
> 
> If you do find the direct answer to your question, please post it, as
> I'm interested in this question also.

P.S. I just noticed lookup_file:
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_
I haven't tried it, but it sounds like it *might* do what you want.


-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: Hello, I think TestRunPerl can save me, but I am not sure how to go about it...

2012-03-15 Thread David Booth
FYI, I tried doing this with using the Test::MockObject module, but
abandoned the effort due to a bug that causes Apache2 child process
segmentation fault even when no Test::MockObject functions are called:
https://rt.cpan.org/Public/Bug/Display.html?id=73723

I don't know if there might have been other workarounds possible.

David

On Thu, 2012-03-15 at 09:28 -0700, Fred Moyer wrote:
> Steve, please direct these questions to the mod_perl list which I have
> cc'd.  You're much more likely to get an answer from any one of the
> thousands of experienced users on this list than emailing any of the
> posters directly.
> 
> On Tue, Mar 13, 2012 at 1:18 PM, Steven Lembark  wrote:
> >
> > Say I have a mod_perl2 handler that does nothing more
> > than pass off its request object to another sub. The
> > sub gets a few things out of $request->args and the
> > headers, proceses its result, and life is good.
> >
> > 99% of the work inside the handler has nothing whatever
> > to do with mod_perl.
> >
> > I would like to run:
> >
> >perl -d submit_a_fake_request;
> >
> > and watch the request get handled.
> >
> > I think that PerlTest or PerlTestRun might offer some
> > way to do this but, but the POD includes only:
> >
> > My::TestRun->new->run(@ARGV);
> >
> > and I have no idea what to pass in as @ARGV.
> >
> > Note that I am not trying to debug Apache itself,
> > just the code that lives below the handler sub. Nor
> > am I writing tests for the most part, I just need
> > to see the code in "perl -d" to find out some things
> > about what is going on inside the code.
> >
> > If this were mod_perl with an HTTP::Request object
> > I could take an old $r->as_string, strip the method
> > and uri, split the headers on newlines, extract the
> > query and construct a new HTTP::Request object. I
> > am trying to duplicate this procedure in Apache2.
> >
> > I'll be happy to hand back POD for the PerlTestRun
> > that shows someone how to assemble a working Apache2
> > request out of as_string output in order to run a
> > test. But several days of stumbling through google and
> > mod_perl archives leave me with no examples that don't
> > already assume that someone knows all of the appropriate
> > arguments and methods to call for setting up an object.
> >
> > Any help would be appreciated.
> >
> > --
> > Steven Lembark 3646 Flora Pl
> > Workhorse Computing   St Louis, MO 63110
> > lemb...@wrkhors.com  +1 888 359 3508
> 
> 

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: [mp2] mod_perl 2.0.7 Segmentation fault in OutputFilter(?)

2013-01-08 Thread David Booth
prb/opt64/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE'
> cccdlflags='-fPIC', lddlflags='-shared -O3 -g -pipe -Wall 
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
> --param=ssp-buffer-size=4 -m64 -mtune=generic -L/usr/local/lib'
> 
> 
> Characteristics of this binary (from libperl): 
>   Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
> PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
> PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT
> USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
> USE_REENTRANT_API
>   Built under linux
>   Compiled at Sep 14 2012 07:38:30
>   @INC:
> /prb/opt64/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux-thread-multi
> /prb/opt64/perl-5.14.2/lib/site_perl/5.14.2
> /prb/opt64/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi
> /prb/opt64/perl-5.14.2/lib/5.14.2
> .
> 
> 
> Many thanx for any hints!
> Petra
> 
> 
> 

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: [OT] AW: Unsuccessful stat on filename containing newline in RegistryCooker.pm

2013-02-28 Thread David Booth

On 02/28/2013 09:32 AM, Torsten Förtsch wrote:

On 02/28/2013 03:14 PM, demerphq wrote:

A special place in hell is reserved for programmers that write code
that assumes that spaces and other unprintables are illegal in a
filename.


Yes, right next door to another place in hell that is reserved for 
people who put spaces and other unprintables in filenames.


David


Re: Initial setup problems with mod_perl2 - unable to locate modules

2014-02-14 Thread David Booth

I used this tutorial to get mod_perl working the first time:
http://perl.apache.org/docs/2.0/user/intro/start_fast.html

Can you get that exact example (Rocks.pm) to work, following those 
instructions?  Please try that first, rather than your actual project, 
just to get the invocation debugged.


David

On 02/14/2014 09:54 AM, Da Rock wrote:

Unfortunately that didn't work in the startup.pl, as has been mentioned
in both replies. Still got the same error with both startup.pl with use
lib , as well as PerlSwitches -I.

I should mention I've tried both modperl and perl-script options to
SetHandler.

There is one other error that shows up in the logs depending on changes
made to the config:

[error] Can't load Perl module

It definitely seems to be an issue with @inc, but what?

TIA guys


On 02/14/14 23:52, John Dunlap wrote:


Do you have a use lib 'PATH'; at the top of your startup.pl
? This is typically how your module is added to the
perl include path

On Feb 14, 2014 8:38 AM, "Da Rock" mailto:mod_p...@herveybayaustralia.com.au>> wrote:

I know this may seem straight forward and a RTFM response may be
in order, but I have been trying to crack this for some days now
(following attempts on and off, too, mind) and nothing I can
google seems to point to an accurate answer on what the problem is
here.

I'm running FreeBSD 9.x with Apache22, and installed mod_perl2 to
try to switch away from php based development based on current
requirements.

I have tried using a startup.pl , but I would
like to just use PerlSwitches -I instead (which from what I read
is possible); regardless the issue remains the same.

I get a 500 response in the browser, and the logs have these errors:

"failed to resolve handler `Mod_home::Mod': Can't locate
Mod_home/Mod.pm in @INC"

and simply "failed to resolve handler" in the main server log.

My config looks like this:

:>
ServerName 
ServerAlias 
ServerAdmin 
ErrorLog "/var/log/apache/-error.log"
CustomLog "/var/log/apache/-access.log" common
PerlOptions +Parent
PerlSwitches -I/usr/local/www//lib
PerlInitHandler Apache2::Reload
PerlModule Mod_home::Mod
>
SetHandler modperl
PerlResponseHandler Mod_home::Mod
Order allow,deny
Allow from all



I also have PerlModule Apache2::Reload in the httpd.conf.

Just to reiterate - I have tried this both as vhosting and as
single server setup, and I cannot seem to resolve the same issue
every single time.

Can someone please give the magical incantation to make this thing
work? :-) or at least point me in the right direction? I'm really
starting to lose patience with this thing, and I now have a
deadline to sort this out which is fast approaching.

Cheers





Re: Apache2::URI::unescape_url bug?

2014-06-26 Thread David Booth

On 06/26/2014 08:42 PM, Mark Hedges wrote:

Try in a handler.  (Apparently you cannot use Apache2::URI from command line?)

use Apache2::Log ();
use Apache2::URI ();
sub handler {
 my ($r) = @_;
 my $string = "6%2D41913%2FUK1";
 Apache2::URI::unescape($string);
 $r->log_error($string);
}

Log contains: 6-41913/UK1\0UK1

??


Not sure what is the intent of your question/comment, but I often use 
uri_unescape in URI::Escape and it seems to work fine.


David



Sharing read/WRITE data between threads?

2021-08-24 Thread David Booth
I am using Apache/2.4.41 (Ubuntu), with mod_perl.  Apache uses multiple 
threads, and I want to share read/WRITE data between threads.  (I.e., I 
want to be able to modify some shared data in one thread, such that 
other threads can see those changes.)  In "Practical mod_perl" Stas 
Bekman describes how to share read-only data between threads, but says 
nothing about how to share WRITABLE data between threads.


Any clues about how this can be done?  I've searched high and low and 
found nothing.  I will also want to know what mechanisms are available 
to coordinate access to that shared data, such as locks or semaphores.


I also posted this message to StackOverflow, but got no response so far:
https://stackoverflow.com/questions/68901260/how-to-share-read-write-data-in-mod-perl-apache2

Any help would be appreciated!

Thanks,
David Booth


Re: Sharing read/WRITE data between threads? [EXT]

2021-08-25 Thread David Booth
Thank you Brad, Jacques and James, for your thoughtful suggestions.  I 
think Brad is right: I should see if I can figure out a different 
approach, instead of trying to do this.  It's looking like it would be 
more trouble than it's worth.  But I'm glad to know about those other 
options in case I need them!


Thanks,
David Booth

On 8/25/21 7:56 AM, James Smith wrote:

The other problem with sharing writable data in "memory" is that it would not 
necessarily shared between multiple server instances. We run multiple mod_perl instances 
for reliability. Agree with other posters either use something like redis or memcache 
(possibly backed with a database).


-Original Message-
From: David Booth 
Sent: 25 August 2021 00:51
To: modperl 
Subject: Sharing read/WRITE data between threads? [EXT]

I am using Apache/2.4.41 (Ubuntu), with mod_perl.  Apache uses multiple threads, and I 
want to share read/WRITE data between threads.  (I.e., I want to be able to modify some 
shared data in one thread, such that other threads can see those changes.)  In 
"Practical mod_perl" Stas Bekman describes how to share read-only data between 
threads, but says nothing about how to share WRITABLE data between threads.

Any clues about how this can be done?  I've searched high and low and found 
nothing.  I will also want to know what mechanisms are available to coordinate 
access to that shared data, such as locks or semaphores.

I also posted this message to StackOverflow, but got no response so far:
https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_68901260_how-2Dto-2Dshare-2Dread-2Dwrite-2Ddata-2Din-2Dmod-2Dperl-2Dapache2&d=DwICaQ&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=oH2yp0ge1ecj4oDX0XM7vQ&m=qpyZVoG2Lx8wqNIB_pQ9wXQkohMh_5Q0HVZmgqmlSbs&s=oUnmv2w8aVNzfIni8nxA0CFh-xrZv1GS8jFquKbzsQM&e=

Any help would be appreciated!

Thanks,
David Booth