Re: Apache::DProf
Think you need to load in Apache::Registry with : PerlModule Apache::Registry before the PerlHandler Apache::Registry bit Suggest also that you do all the module loading / startup before specifying any handlers eg . from my mod_perl.conf PerlRequire conf/startup.pl PerlFreshRestarton PerlSetVar StatusOptionsAll On PerlSetVar StatusTerse On PerlSetVar StatusTerseSize On PerlSetVar StatusTerseSizeMainSummary On Alias /perl-bin/ /usr/local/apache/mod_perl/ PerlModule Apache::DProf PerlModule Apache::Registry PerlModule B::TerseSize PerlModule Apache::Status Location /perl-bin SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader On allow from all /Location On Wednesday 24 Jul 2002 2:20 pm, Ruslan V. Sulakov wrote: I have troubles using Apache::DProf I try to use it as described at: http://perl.apache.org/docs/1.0/guide/performance.html#Code_Profiling_Techn i ques But when my httpd.conf has a line: PerlModule Apache::DProf apache reply with error 500 (Internal Server Error) when I request a perl script, that runs under mod_perl Without this line, all works fine! Errorlog shows following message during each request: [Sat Jul 20 07:34:28 2002] [error] Undefined subroutine Apache::Registry::handler called. I have in my httpd.conf Files *.pl SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader On Options +ExecCGI PerlModule Apache::DProf PerlRequire /path/to/my/modules/modperl_startup.pl /Files Is here something wrong? How can I have Apache::DProf worked for profiling my code? Thanks in advance. Ruslan
hiding perl code
see attached =head1 NAME BZS::License - Perl extension to examine a license file. =head1 USEAGE There are two modes of operation: use BZS::License;1; __END__ encrypted module here... The calling routine should define an anonymous hash pointed to by the variable $ptr2_License. i.e. use vars qw( $ptr2_License ); $ptr2_License = { 'private' = 'name1, name2,...', # use private key # module name 'path' = 'path to License file', }; require licensed_module_name; Or, for nested modules, a reference pointer to point back to the originating module containing the License information. use vars qw( $ptr2_License ); $ptr2_License = { 'next' = 'any value will do', }; require licensed_module_name; Seconds remaining until License expiration are returned in $ptr2_License{expires} unless there is no expiration Warnings if any will be in $ptr2_License-{warn} It is important the 'require' instead of 'use' loads the module so that $ptr2_License is visible to the loader and not forgotton in the case of mod-perl so don't enclose a in BEGIN{} block. Version checking is not supported via 'use' like statement. It can be done by examining the module contents. More automated setup can be accomplished with the BZS::License::Util tools. use BZS::License::Util; See BZS::License::Util documentation for complete description The second module mode is for development use and just loads the module so its objects can be accessed; use BZS::License; $time = BZS::License::date2time(date string); @file_text = BZS::License::get_file(file_path); $first_tag_number = BZS::License::extract(\@file_text,\%parms); BZS::License::get_vals(\%parms); =head1 DESCRIPTION See the documentation for BZS::Loader for details of License loading operation. Only the differences are covered here. BZS::License performs a similar load operation to BZS::Loader. First, however it looks for a hash pointer in the caller program called $ptr2_License. The hash contains the path to the License file and an optional 'private' key list of modules which will decrypt only with the 'private' key. BOR, a hash key of 'next' with no particular value that indicates to look to the next caller on the stack for the License pointer. If the pointer is not present or the License file is not found successfully, then no further action is taken. If the License file is successfully opened, and the contents validated then the attached encrypted module is loaded and the seconds remaining until License expiration are returned or now() in the case of no expiration. Undef is returned for an expired license (module fails to load). =over 4 =item This is what is in a certificate License Text followed by: ID::unique licensee identifier, date code is fine NAME: :company or entity name ADD1: :address line 1 ADD2: :address line 2 CITY: :city STATE: :state or province ZIP: :postal code CTRY: :country TEL: :telephone number FAX: fax number CONT: :contact person MAIL: :email addy of contact -- SERV: :http server name * optional HOST: :hostname * optional USER: :calling user * optional GROUP: :calling group * optional HOME: :called from withing this path * optional -- DATE: :creation date, mm-dd-yy | or mmm dd yy | EXP: :expiration * optional KEY: :hex key PKEY: :hex public key -- =item $time = BZS::License::date2time(date string) Converts a string into a numeric time value as returned by the perl function 'time' else 0; * acceptable date formats mm/dd/yy mm-dd-yy mm dd yy month day year month = text or digits month day, year actually any combination of separators [/- ] will work commas are always deleted, white space compressed, etc... =item @file_text = BZS::License::get_file(file_path) Takes the file path/name as its argument. Returns the stripped file contents suitable for MAC calculation in an array. On failure, returns an empty array. =item MAC calculation The MAC signature is created by taking the MD5 sum of the file less MAC the line (if present). Leading blank lines are removed, all tabs are converted to single spaces and trailing white space is snipped to avoid complications caused by cut and paste operations. MAC calculation is only done on the text portion of the file. =item $first_tag_num = BZS::License::extract(\@file_text,\%parms) Bextract takes an input array consisting of the lines of text in the License and returns the \%parms hash
[mp 2.0] v2.0.40 dev of apache
Thanks, Ward. Now that I know this list is active, I've a question. I know the development versions are all that is released of 2.0.40 of Apache2, however, I have a need to use them due to 2.0.39's incompatibilities w/several key features of PHP (can you say 'multiple cookies broken'?). Having said that, If I upgrade to 2.0.40, modperl 1.99_04 breaks with an AWFUL msg during compile time. (This is not the forum to troubleshoot the compile, though) so I will just say does anyone know the average difference between an Apache 'official' release and the mod_perl official release supporting it? My question is kind of Out there I know...but since I must use 2.0.40 of Apache2, I do not wish to lose my mod_perl which is actually more important to me. Any ideas? Is there a dev cvs site for 'unreleased' modperl builds which we can log in on? Is there a separate team developing mod_perl or is is still Mr. Stein? I know, I know...lots of questions. Thanks in advance. Jann On 7/24/02 3:45 PM, Vuillemot, Ward W [EMAIL PROTECTED] wrote: i just got your message : -Original Message- : From: Jann Linder [mailto:[EMAIL PROTECTED]] : Sent: Wednesday, July 24, 2002 3:44 PM : To: [EMAIL PROTECTED] : Subject: Is this list still active? : : : Just wanted to know. Haven't gotten any posts for awhile. : : : Thx. : : Jann : -- Mr. Jann Linder Director of Internet Development DinnerBroker/Pricing Dynamics, Inc. San Francisco, CA 1-888-iEATat8 x235
Re: [mp 2.0] v2.0.40 dev of apache
On Wed, 24 Jul 2002, Jann Linder wrote: Any ideas? Is there a dev cvs site for 'unreleased' modperl builds which we can log in on? http://perl.apache.org/contribute/cvs_howto.html Is there a separate team developing mod_perl or is is still Mr. Stein? I think you are a bit confused here. :-) Greg Stein made mod_dav. mod_perl is primarily written by Doug MacEachern. http://perl.apache.org/about/contributors/people.html There's a mailinglist for the development of the mod_perl internals. - ask ps. if you are not receiving frequent messages from the list you are probably not subscribed. Send mail to [EMAIL PROTECTED] to change that. -- ask bjoern hansen, http://askbjoernhansen.com/ !try; do();
PerlSendHeader and $r-header_out
Hi People With Functioning Brain Cells, I'm having a brief period of grief, which I'm sure I've been through before. I have this situation where I set a cookie using: $r-header_out('Set-Cookie'=$cookie); Now this is all fine, however I'm having a major problem in getting my header into the right place. If I call $r-send_http_header right after my $r-header_out(set_stuff) directive, and then call $r-print(page contents), I get: page_contents HTTP_HEADERS DISPLAYED HERE (INCLUDING COOKIE HEADER) Now, I experimented with PerlSendHeader being set to On, whilst disabling the call to $r-send_http_header, yet it then appears to give me a header which doesn't include the cookie header: HTTP/1.1 200 OK Date: Thu, 25 Jul 2002 13:01:12 GMT Server: Apache/1.3.20 (Linux/SuSE) PHP/4.0.6 mod_perl/1.26 Transfer-Encoding: chunked Content-Type: text/html Any idea what is going on? I'd like to just send_http_header with the headers appearing on top of my page. It appears to do things in the wrong order. There is no duplication of headers either. If anyone can help and would fancy flying me out, I'll even buy you a beer. :) My content handler returns the result of another method called within the same module. This method is passed the request object, which in turn it uses to send the headers and print the page. This seems 'sensible' to me; so why is it not working?? Many Thanks, Fiq We're so wonderfully wonderfully wonderfully Wonderfully pretty Oh you know that I'd do anything for you We should have each other to tea, huh? We should have each other with cream Then curl up by the fire And sleep for awhile It's the grooviest thing It's the perfect dream - The Cure, Love Cats.
reading an ENV with Perl that was set with mod_rewrite [E= : ]
Hi, Has anyone used mod_rewrite to set an environmental variable based on the result of a reg exp? For example: RewriteRule ^/pt=([^/]+)?(.*) /home/me.com/public_html/$2 [E=PT:$1] I can get a static url like: RewriteRule /perl /usr/local/apache/perl/printenv [E=ERIC:bob] to work, but the first one I can't. PT doesn't exist, but ERIC does. I know this is not exactly on topic, but it is a weird sort of issue, the admin I was dealing with said he could get the above ENV with PHP or mod_perl but not with perl CGI's I can't seem to get it with a mod_perl Registry script either though. Thanks, Eric http://www.kwinternet.com/eric (250) 655 - 9513 (PST Time Zone) Inquiry is fatal to certainty. -- Will Durant
Problem: Apache2 / Perl 5.8.0 / mod_perl 2.0 / PHP all on Win32
I am in a bit of a jam. I think the cross-post is necessary since I need the help of Apache, mod_perl, and PHP developers/users. I apologize for the length, if you have time, my explanation (at the end) should clarify what I mean. Summary --- I need: - A perl-enabled web server to run on the win32 platform - mod_perl to allow for persistent (stay connected on the server side) Net::Telnet objects (CGI is unacceptable since a new process is spawned at each request leaving no room for persistent objects) - Multiple perl interpreters of Apache2 / mod_perl 2.0 to serve more than one mod_perl request at a time - Access to the client's Net::Telnet object during all of his/her requests throughout his/her session - I might need Perl 5.8.0 for threads::shared to solve the above problem - A way for mod_perl scripts to communicate with PHP scripts quickly and efficiently Does anybody know what kind of configuration I could use to support all of my needs above? Does anybody know another way for mod_perl 2.0 and PHP to communicate other than apache_notes (if it's true I can't use apache_notes with Apache2 / PHP 4.2.X)? If a solution is not available now (ie. I can't share Net::Telnet objects in different requests, or, PHP isn't fully supporting Apache2), when will it be available (if ever)? Thanks for your time and any help, Shawn Brief (?) Explanation - I need a win32 server to provide a sort of web-interface to perl Net::Telnet objects (which is just a wrapper for telnet sessions written in perl). These objects open sockets/file_handles on the server and have to be accessible to my server-side scripts throughout multiple client requests. ie. A session for Client_123 might look like: Request 1: Client_123's telnet object is initialized (connects to a remote telnet host) Request 2 - n-1: A script on the server executes commands on Client_123's telnet connection Request n: Client_123's telnet object is destroyed From mod_perl 2.0 docs (http://perl.apache.org/docs/2.0/os/win32/install.html): A mod_perl 1.0 enabled server based on Apache 1.3 on Win32 is limited to a single thread serving a request at a time. This effectively prevents concurrent processing, which can have serious implications for busy sites. This problem is addressed in the multi-thread/multi-process approach of mod_perl 2.0/Apache 2.0 Obviously I need Apache2/mod_perl2 if I want to be able to have more than one client request executing perl code at the same time. However, I need to make sure that the Net::Telnet object is accessible (ie. in shared memory, indexed by the clients session_id) for all of Client_123's request. I was told that I might be able to use threads::shared to keep the Net::Telnet objects accessible by multiple mod_perl threads in mod_perl2 and Perl 5.8.0 so that shouldn't be a problem... as long as I use Apache2 / mod_perl 2.0 / Perl 5.8.0. Thrown in to the mix is the fact that I need some PHP scripts to communicate (transfer parameters) to mod_perl scripts, and for the mod_perl to transfer the results back to the PHP scripts. I have this working using apache notes in Apache1.3.26 / mod_perl 1.27 / PHP 4.21. However (as mentioned above) only one mod_perl request (involving telnet stuff) can be served at a time so I need to upgrade to Apache2, where there isn't apache_note support (http://bugs.php.net/bug.php?id=17557).
Re: .bml files not executing in apache
On Tue, 23 Jul 2002, randy reed wrote: Hi Randy, Thanks for your reply. Please excuse my utter newbie status at all this. Ok, looking at your message and the documentation for mod_perl as well as the LJ documentation here's what I see. BML is actually setup up as a perl module Apache::BML its excuted in a file called modperl.pl In httpd.conf there is a PerlRequire c:/livejournal/cgi-bin/modperl.pl but, as you can see if you try to get on my site (www.thefreemachine.cc/index.bml) it doesn't excute. So whats missing that would get httpd to call it when it receives a request for a .bml file. Is there something I'm missing here (this is running on a windows machine), the code seems fairly straightforward PerlInitHandler +Apache::LiveJournal DirectoryIndex index.html index.bml }); unless ($LJ::SERVER_TOTALLY_DOWN) { Apache-httpd_conf(qq{ # BML support: PerlSetVar BMLDomain lj-$LJ::DOMAIN PerlModule Apache::BML Perl Apache::BML::load_config(lj-$LJ::DOMAIN, $LJ::HOME/cgi-bin/bmlp.cfg); /Perl Files ~ \\.bml\$ SetHandler perl-script PerlHandler Apache::BML /Files }); } I'm not familiar enough with how the bml stuff works to offer anything specific there to look at. Is there anything in the error logs that might help? Also, are you sure that that c:/livejournal/cgi-bin/modperl.pl is successfully loaded, and in particular that variables like $LJ::DOMAIN and $LJ::SERVER_TOTALLY_DOWN are reaching Apache-httpd_conf()? And is the bmlp.cfg file being read? One way to check these things is to put some print statements in various locations to let you know that that point is being reached. -- best regards, randy kobes
DBI handle management in modules
I have a number of perl modules that manage their own persistence to a SQL database via DBI. I discovered a flaw in my current approach which was to use an Apache::Singleton::Process object to create a connection and in modules that needed a connection, store the connection in a lexically scoped variable near the top of the module. The problem I found with this approach is that I am essentially caching the database connections at module load time, so if the database connection goes away (which it does from time to time because of things like the database server getting restarted), the now broken connection continues to be used. The code (after quite a bit of distillation) looks basically like: package MyPersistentObject; use strict; use warnings; use MyProject::Dbh; my $dbh = MyProject::Dbh-instance-dbh; ### sub method1 { my ($self, $id) = @_; $dbh-do(qq[delete from table1 where id=?], undef, $id); } #... package MyProject::Dbh; use strict; use warnings; use Apache::Singleton::Process; use base (Apache::Singleton::Process); sub _new_instance { return DBI-connect($dsn, $user, $pass, {RaiseError = 1}); } - httpd.conf has: Perlrequire /pathgoeshere/startup.perl and starutp.perl has: use Apache::DBI; What I'm basically trying to accomplish is: 1) Make database connection in one place in the code. 2) Not have to pass $dbh all over the place, but instead have modules that need a database connection get it themselves. 3) Connection only needs to happen once per request. If the connection dies during a request, the next query using that request should fail, and the next request serviced by that child process should get a new connection. 4) I don't want to call 'connect' before every query because the overhead is too high, even when Apache::DBI returns a pooled connection. 5) For one request, only one connection should be used (i.e, the connection should be a request singleton). 6) Modules that require DBI connections should not be dependent on a mod_perl environment. I.e. they should also be usable in command line scripts. What I have come up with so far is to rewrite the connection handling as follows, which also seems to remove the need for Apache::DBI: package MyProject::DbhSingleton; use Apache::Singleton::Request; use base (qw Apache::Singleton::Request); sub _new_instance { my $dbh = DBI-connect($dsn, $user, $pass, $attr) or die DBI-errstr; } The thing I'm not sure about is when should I be calling this to get a local copy of $dbh in a module. I know that calling it only at module use time is not frequent enough, and calling it before every query is too frequent (too expensive), but I'm not sure of a happy medium. For some objects, calling MyProject::DbhSingleton-instance to store a dbh as a instance data would suffice, but not in all cases. I've looked through the guide and done a number of web searches but have not found anything that directly addresses this. Any help would be greatly appreciated -- [EMAIL PROTECTED]
IPC::MM and mod_perl
This may be more of an Apache question, but I saw a thread in the mod_perl archives on caching methods that is relevant. I'd like to use IPC::MM to store data in shared memory across child processes, but I've run into permissions problems. I'm assuming this is because I'm creating the cache in startup.pl which is run by root, and trying to store data in a child process that is run as user apache. If I create the cache in a child process, I can write to it, but lose the ability to use it in other child processes. The IPC::MM perldoc mentions file permissions, but I think that's for a file-based cache, which doesn't apply here. I could be wrong on that and just setting the permissions incorrectly. I haven't found a lot of documentation about using this library, so maybe this isn't the proper way for it to be used. I'm on Linux (RH 7.3/2.4.18-3) and apache 1.3.22. Thanks, mk