PerlModule lifetime / threads
Hey all, I am trying to port a module I wrote in C to one that uses mod_perl. The C module would spawn a thread in the child_init process and poll a file. The file polled contained data that the header parser phase would use. I protected the data via a RW Lock. Now when doing this in mod_perl I see the following things: if I have a ChildInitHandler, any changes I make to globals are not reflected in a HeaderParserHandler. My globals do not have the :shared attribute - must they? I've had better luck getting rid of the ChildInit directive and initializing globals like a normal script. Then my handler routine can see what I've initialized. I can even spawn a thread. Unfortunately, changes to a shared array that my thread makes are not picked up by the handler. I'm definitely missing something here as I'm approaching this from a C module perspective where I had access to the right hooks and knew what process I'd be running in. Is there a way to do what I want in mod_perl - namely have a HeaderParserHandler that uses data for some logic where that data is updated from some other thread that I spawn? Thanks, SB
Truoble getting Apache::AuthCookie to work on server
After getting it to work just fine on my desktop, without any virtual hosts, I can't get it to work right on my server in a virtual host. Using OpenBSD, older -current, chrooted, all mod_perl after adding some debugging warns, I get this username= cool at /usr/local/libdata/perl5/site_perl/MyPerl/Utils.pm line 13. password = yellow at /usr/local/libdata/perl5/site_perl/MyPerl/Utils.pm line 14. I am not getting correct previous uri: (should be /protected/index.html) uri = /perl/login.pl at /var/www/htdocs/users/edett.us/perl/login.pl line 13. Use of uninitialized value $creds in concatenation (.) or string at /var/www/htdocs/users/edett.us/perl/login.pl line 15. creds = at /var/www/htdocs/users/edett.us/perl/login.pl line 15. Use of uninitialized value $reason in concatenation (.) or string at /var/www/htdocs/users/edett.us/perl/login.pl line 36 I have tried with both version 3.12 and 3.14 Thanks Chris Bennett -- A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. -- Robert Heinlein
Re: Truoble getting Apache::AuthCookie to work on server
Chris Bennett wrote: After getting it to work just fine on my desktop, without any virtual hosts, I can't get it to work right on my server in a virtual host. I have Apache::AuthCookie (and several derived versions) working fine in multiple VirtualHost sections, on several servers. I just mention this so that you would not think that there is some incompatibility between Apache::AuthCookie and VirtualHost setups. There isn't. Apart from that, it is difficult to help you without having any idea of your configuration (meaning the main httpd.conf and the virtual hosts config, your login form etc..).
Re: PerlModule lifetime / threads
On Wed, May 19, 2010 at 4:37 PM, Some Guy wrote: > if I have a ChildInitHandler, any changes I make to globals are not > reflected in a HeaderParserHandler. My globals do not have the :shared > attribute - must they? Only if you're trying to update them from a different thread. If there aren't multiple threads involved, you can update globals from anywhere. If that's not working for you there's probably a mistake in the way you're referring to the variables. If you post some code we may be able to help. > Is there a way to do what I want in mod_perl - > namely have a HeaderParserHandler that uses data for some logic where that > data is updated from some other thread that I spawn? A more common approach with perl is to make a handler that runs in an early phase which reloads the data as needed, and not use a separate thread. If you're concerned about reloading the data adding too much delay to a web request, you could do this in a cleanup handler. - Perrin
ExtFilterDefine persistency
If I haven't sent this to the correct place please inform me. I've look through the assorted documentation, both mod_perl and Apache, and haven't found a solution to my situation. I've also given the internet a try with no luck. I admit I'm new to mod_perl. I've installed mod_perl onto an Apache server, version 2.2.15, Windows XP, and have it running. I'm running Perl 5.8.8 I've inserted the following line into my httpd.conf file: ExtFilterDefine IpCount mode=input cmd="C:/perl/bin/perl.exe C:/Apache22/cgi-bin/ip_count.pl". The file ip_count.pl will execute just fine but because I have to load the Perl interpreter each time, and I can't specify a URL, the performance is less than desired. No persistency. Is there a way to have mod_perl handle its execution by specifying something other than "C:/perl/bin/perl.exe"? Thank You
Re: Truoble getting Apache::AuthCookie to work on server
On 05/19/10 17:11, André Warnier wrote: Chris Bennett wrote: After getting it to work just fine on my desktop, without any virtual hosts, I can't get it to work right on my server in a virtual host. I have Apache::AuthCookie (and several derived versions) working fine in multiple VirtualHost sections, on several servers. I just mention this so that you would not think that there is some incompatibility between Apache::AuthCookie and VirtualHost setups. There isn't. Apart from that, it is difficult to help you without having any idea of your configuration (meaning the main httpd.conf and the virtual hosts config, your login form etc..). I am working off the example from mod_perl cookbook relevant part of startup.pl use Apache::RegistryBB(); use Apache::Request(); use Apache::Cookie(); use HTML::Entities(); use Encode(); use List::Util(); use Getopt::Std(); use MIME::Parser(); use Mail::POP3Client(); use HTML::Tagset(); use HTML::Parser(); use HTML::TreeBuilder(); #require HTML::FormatText(); #require B::TerseSize(); use Cwd(); use Apache::DBI(); use DBD::Pg(); use Carp::Heavy(); use Exporter(); use File::Copy(); use Apache::AuthCookie::Util(); use Apache::AuthCookie(); use MyPerl::FormEmail2(); use MyPerl::FormEmail3(); use MyPerl::Articulator(); use MyPerl::ArticulatorBETA(); use MyPerl::Utils(); use MyPerl::Authenticate(); ### use lib qw(/var/www/var/www/htdocs/users/mwforum/cgi/mwf); use MwfConfigLSMB(); use MwfConfigCAPU(); use MwfMain(); use MwfConfigGlobal(); use MwfCGI(); use MwfDefaults(); use MwfEnglish(); use MwfGerman(); use MwfPlgIncludeCAPU(); use MwfPlgIncludeLSMB(); use MwfCaptcha(); use DBD::mysql(); use Carp(); require qw(utf8_heavy.pl); require qw(unicore/PVA.pl); require qw(unicore/Exact.pl); require qw(unicore/Canonical.pl); require qw(unicore/To/Fold.pl); require qw(unicore/lib/gc_sc/SpacePer.pl); use Apache::Constants(); use Apache::Connection(); use Apache::File(); use Apache::Util(); use Apache(); use POSIX(); use IPC::Run(); use Digest::MD5(); use Time::HiRes(); use GD(); use Unicode::Normalize(); use Mail::Sender(); use MIME::QuotedPrint(); ## #use CGI(); #use CGI::Carp(); require qw(/usr/local/libdata/perl5/site_perl/auto/Image/Size/jpegsize.al); use Image::Size(); use DB_File(); I have httpd.conf split up with individual conf files for gzip, SSL, and each virtual host and its SSL, if relevant. httpd.conf: # $OpenBSD: httpd.conf,v 1.19 2006/02/22 15:07:12 henning Exp $ ServerType standalone ServerRoot "/var/www" PidFile logs/httpd.pid ScoreBoardFile logs/apache_runtime_status Timeout 45 LimitRequestBody 10485760 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 15 MinSpareServers 5 MaxSpareServers 10 StartServers 5 MaxClients 150 MaxRequestsPerChild 0 MaxCPUPerChild 0 MaxDATAPerChild 0 MaxNOFILEPerChild 0 MaxRSSPerChild 0 MaxSTACKPerChild 0 Listen *:80 Listen *:8080 Listen *:8081 # Note: The order is which modules are loaded is important. Don't change # the order below without expert advice. # "anonymous" user access to authenticated areas # LoadModule anon_auth_module /usr/lib/apache/modules/mod_auth_anon.so # user authentication using Berkeley DB files # LoadModule db_auth_module /usr/lib/apache/modules/mod_auth_db.so # user authentication using DBM files # LoadModule dbm_auth_module/usr/lib/apache/modules/mod_auth_dbm.so # authentication using new-style MD5 Digest Authentication (experimental) LoadModule digest_auth_module /usr/lib/apache/modules/mod_auth_digest.so # CERN httpd metafile semantics # LoadModule cern_meta_module /usr/lib/apache/modules/mod_cern_meta.so # configuration defines ($xxx) # LoadModule define_module /usr/lib/apache/modules/mod_define.so # user authentication using old-style MD5 Digest Authentication # LoadModule digest_module /usr/lib/apache/modules/mod_digest.so # generation of Expires HTTP headers according to user-specified criteria # LoadModule expires_module /usr/lib/apache/modules/mod_expires.so # customization of HTTP response headers # LoadModule headers_module /usr/lib/apache/modules/mod_headers.so # comprehensive overview of the server configuration # LoadModule info_module/usr/lib/apache/modules/mod_info.so # logging of the client user agents (deprecated in favor of mod_log_config) # LoadModule agent_log_module /usr/lib/apache/modules/mod_log_agent.so # logging of referers (deprecated in favor of mod_log_config) # LoadModule referer_log_module /usr/lib/apache/modules/mod_log_referer.so # determining the MIME type of a file by looking at a few bytes of its contents # LoadModule mime_magic_module /usr/lib/apache/modules/mod_mime_magic.so # mmap()ing of a statically configured list of frequently requested but # not changed files (experimental) # LoadModule mmap_static_module /usr/lib/apache/mod