Re: Initializing Sleepycat::DbXml (Berkeley, Oracle) objects in startup.pl
Mark Hedges schrieb: On Thu, 15 Jan 2009, Michael Ludwig wrote: PerlRequire /home/milu/www/eumel/startup.pl PerlChildInitHandler Eumel::Gurke::bla; PerlChildExitHandler Eumel::Gurke2::bla; No trailing semicolons? That was a copy and paste error when composing the mail. But this is an important point, as there won't be any warning about this - it will silently fail, regardless of whether or not the module has been loaded. Probably if you first do PerlLoadModule Foo::Bar it will fail and inform you It definitely will fail and output an error message. So it's crucial to PerlLoadModule the module first, else even a correctly specified PerlChildExitHandler won't be installed. Thanks a lot, Mark. More on this later. Michael Ludwig
Re: Initializing Sleepycat::DbXml (Berkeley, Oracle) objects in startup.pl
macke...@animalhead.com schrieb: Apache is forgiving/robust about specifying nonexistent phase handlers in httpd.conf and inserts thereto. Thanks. I noticed. :-) I was using event, and had to let each thread open its own DBs based on an undefined global. Then I found that the identical traffic-test exerciser could get 66 files/second back in event and 1500/second in prefork. This is under FreeBSD 6.3. No doubt I had something wrong or tunable in event, but at that point I gave up and will wait for the simple MPM. Thanks. I'll try prefork if I can't get worker to work. Michael
Separate Error log for each virtual host
I would like to configure apache such that the errors for a specific virtual host get logged in their own file. I tried something like this: VirtualHost *:8080 ErrorLog C:/location/of/acd/logs/error.log Perl use lib 'C:/location/of/acd'; $ENV{MODE} = 'development'; /Perl ScriptAlias / C:/locattion/of/acd Location / SetHandler perl-script PerlHandler ACD::Dispatch Order allow,deny Allow from all /Location /VirtualHost But it seems to be ignoring my ErrorLog directive and still puts the logs in the regular place. What am I doing wrong? -- -fREW
Re: Separate Error log for each virtual host
fREW Schmidt wrote: I would like to configure apache such that the errors for a specific virtual host get logged in their own file. I tried something like this: VirtualHost *:8080 ErrorLog C:/location/of/acd/logs/error.log Perl use lib 'C:/location/of/acd'; $ENV{MODE} = 'development'; /Perl ScriptAlias / C:/locattion/of/acd Location / SetHandler perl-script PerlHandler ACD::Dispatch Order allow,deny Allow from all /Location /VirtualHost But it seems to be ignoring my ErrorLog directive and still puts the logs in the regular place. What am I doing wrong? Are there other virtual hosts too? That config would make that particular vhost put it's error_log at C:/location/of/acd/logs/error.log. Typically people just have a different path in their ErrorLog directive for each vhost. Adam
Re: Separate Error log for each virtual host
On Fri, Jan 16, 2009 at 9:59 AM, Adam Prime adam.pr...@utoronto.ca wrote: fREW Schmidt wrote: I would like to configure apache such that the errors for a specific virtual host get logged in their own file. I tried something like this: VirtualHost *:8080 ErrorLog C:/location/of/acd/logs/error.log Perl use lib 'C:/location/of/acd'; $ENV{MODE} = 'development'; /Perl ScriptAlias / C:/locattion/of/acd Location / SetHandler perl-script PerlHandler ACD::Dispatch Order allow,deny Allow from all /Location /VirtualHost But it seems to be ignoring my ErrorLog directive and still puts the logs in the regular place. What am I doing wrong? Are there other virtual hosts too? That config would make that particular vhost put it's error_log at C:/location/of/acd/logs/error.log. Typically people just have a different path in their ErrorLog directive for each vhost. Yeah, I have another virtualhost at *:80 with it's own ErrorLog directive, but of course it still doesn't seem to honor that and puts the errorlog in the default place anyway. -- -fREW
Re: Initializing Sleepycat::DbXml (Berkeley, Oracle) objects in startup.pl
macke...@animalhead.com wrote: Apache is forgiving/robust about specifying nonexistent phase handlers in httpd.conf and inserts thereto. I was using event, and had to let each thread open its own DBs based on an undefined global. Then I found that the identical traffic-test exerciser could get 66 files/second back in event and 1500/second in prefork. This is under FreeBSD 6.3. No doubt I had something wrong or tunable in event, but at that point I gave up and will wait for the simple MPM. The event MPM is also currently referred to as being 'experimental' by the httpd folks. have you tried worker instead? Adam
Re: Separate Error log for each virtual host
fREW Schmidt wrote: Yeah, I have another virtualhost at *:80 with it's own ErrorLog directive, but of course it still doesn't seem to honor that and puts the errorlog in the default place anyway. This doesn't really have anything to do with mod_perl at all i think you might want to try removing all the mod_perl stuff and getting your logging working how you want, then add the mod_perl stuff back in. It's kind of unusual to have an ErrorLog directive and not have an AccessLog directive. It's also unusual to not have ServerName/ServerAlias defined when you're using * in a VirtualHost directive. It's also unusual (at least IMO) to not have a DocumentRoot defined for the vhost. Adam
Re: Separate Error log for each virtual host
Yeah, I have another virtualhost at *:80 with it's own ErrorLog directive, but of course it still doesn't seem to honor that and puts the errorlog in the default place anyway. This doesn't really have anything to do with mod_perl at all i think you might want to try removing all the mod_perl stuff and getting your logging working how you want, then add the mod_perl stuff back in. It's kind of unusual to have an ErrorLog directive and not have an AccessLog directive. It's also unusual to not have ServerName/ServerAlias defined when you're using * in a VirtualHost directive. It's also unusual (at least IMO) to not have a DocumentRoot defined for the vhost. I'll look at the AccessLog and ServerName/ServerAlias stuff. There IS a document root for the other Virtual Host, and I will add one for this one right now. Once I have dealt with those issues I'll post again. Thanks! -- -fREW
Re: Initializing Sleepycat::DbXml (Berkeley, Oracle) objects in startup.pl
I started with 'worker', and it had similar performance to what I saw thereafter with 'event'. Actually slightly better, perhaps because 'event' gained no advantage from KeepAlive because each test process stayed locked to one connection. 'worker' and 'event' were experiments that I decided to terminate, in part because I was so annoyed with Perl ithreads after I had laboriously eliminated many global variables from my mod_perl scripts that didn't want to be shared. This activity was based on the Programming Perl description of threads 5.005. Oh well, now the code should be better set for the future. Best Regards, cmac www.animalhead.com On Jan 16, 2009, at 8:14 AM, Adam Prime wrote: macke...@animalhead.com wrote: Apache is forgiving/robust about specifying nonexistent phase handlers in httpd.conf and inserts thereto. I was using event, and had to let each thread open its own DBs based on an undefined global. Then I found that the identical traffic-test exerciser could get 66 files/second back in event and 1500/second in prefork. This is under FreeBSD 6.3. No doubt I had something wrong or tunable in event, but at that point I gave up and will wait for the simple MPM. The event MPM is also currently referred to as being 'experimental' by the httpd folks. have you tried worker instead? Adam
Re: Apache2::Reload: Where is it?
fREW Schmidt wrote: [Thu Jan 15 17:34:21 2009] [error] Can't locate Apache2/Reload.pm in @INC (@INC contains: C:/usr/site/lib C:/usr/lib . C:/Program Files/Apache Software Foundation/Apache2.2) at (eval 3) line 3.\n [Thu Jan 15 17:34:21 2009] [error] Can't load Perl module Apache2::Reload for server (null):0, exiting... Apache2::Reload is currently not part of the modperl2 libraries (not in libapreq2 either). You have to download the source file from cpan, and put the library files in the appropriate perl/site/lib/ folder. No further config changes required.
[BUG] CGI param does not reset
Hello, I just built a new vanilla server, Apache/2.0.63 (Unix) mod_perl/2.0.4 Perl/v5.8.0 under Solaris 10. I noticed that the $cgi-param does not reset in the mod_perl directories. When I run the following program, it works fine under the standard cgi-bin, but produces what appears to be cached results under mod_perl: Program: use CGI; my $cgi=new CGI; print $cgi-header; print a href=test.pllink 1 (no x)/a a href=test.pl?x=1link 2 (with x)/a x=.$cgi-param('x').br\n; print REQUEST_URI:$ENV{REQUEST_URI}br\n; print QUERY_STRING:$ENV{QUERY_STRING}br\n; print CGI Version: $CGI::VERSION; Under my mod_perl directory, if I click the link 2 I get this: link 1 (no x) link 2 (with x) x=1 REQUEST_URI:/gciti/test.pl?x=1 QUERY_STRING:x=1 CGI Version: 2.91 When I click link 1, I get this: link 1 (no x) link 2 (with x) x=1 REQUEST_URI:/gciti/test.pl QUERY_STRING: CGI Version: 2.91 Notice that 1 continues to show up in x=1. If I wait a few minutes or repeatedly click link 1, it eventually clears up: link 1 (no x) link 2 (with x) x= REQUEST_URI:/gciti/test.pl QUERY_STRING: CGI Version: 2.91 It doesn't matter which CGI version I use. Here is my mod_perl location configuration in httpd.conf: Location /myperl SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI /Location I appreciate any help you can offer. My searches come up empty on this. Thanks, JT
Re: Separate Error log for each virtual host
On Fri 16 Jan 2009, fREW Schmidt wrote: I would like to configure apache such that the errors for a specific virtual host get logged in their own file. I tried something like this: VirtualHost *:8080 ErrorLog C:/location/of/acd/logs/error.log Perl use lib 'C:/location/of/acd'; $ENV{MODE} = 'development'; /Perl ScriptAlias / C:/locattion/of/acd Location / SetHandler perl-script PerlHandler ACD::Dispatch Order allow,deny Allow from all /Location /VirtualHost But it seems to be ignoring my ErrorLog directive and still puts the logs in the regular place. What am I doing wrong? Are you wondering why all your warn() output is directed to only one log file? If yes, then try the logging functions in Apache2::Log instead. I don't know about windows but on a UNIX-like system the default ErrorLog is opened on file descriptor 2 and that happens to be STDERR. That's why all the perlish warn()ings go to that file. You will notice that the methods in Apache2::Log all require a request or server object. This is necessary to decide into which error log the message should be written. Since the perl warn() lacks that information it cannot log to a specific file. You can override the warn() by either supplying a $SIG{__WARN__} handler or by implementing *CORE::GLOBAL::warn=sub {...}. That function can then check if Apache2::RequestUtil-request or Apache2::ServerUtil-server returns something useful and the use that object with Apache2::Log. If your Apache error messages all go to the same file then your configuration is wrong. If you use named virtual hosts you have perhaps forgotten the ServerName directive (as Adam pointed out) or your requests lacks the Host-header. I think Apache complains in that case at startup. Turn on LogLevel debug. For IP/port based vhost you don't need either. Torsten -- Need professional mod_perl support? Just hire me: torsten.foert...@gmx.net
generic enquiry about rendering zipped content
Hi. Question : What exact form would a HTTP response need to have, for the browser to correctly interpret that the response it is getting is a document (for example an OpenOffice document or an email in eml format), but which has been zipped for transmission ? What I would like to happen is that the browser receives the zipped document, but instead of proposing to open it as a zip file or save it to disk as a zip file, unzips it and handles it properly as per the content of the zipped response. I know that this has to do with the Content-Type and Content-disposition and Content-encoding (Content-type-encoding ?) headers, but do not know exactly what are the caveats or rules or things that work with one browser and not the other kind of stuff. Does anyone know ? If more context is required : A server-side application stores on the one hand original documents of different kinds, zipped, and on the other hand meta-data about these documents in a database and search-engine. The user can search the database, and obtain a response html page, on which appear icons representing the original documents. When clicking on such an icon, the user should receive the original document. It seems a pity, considering that the document is already stored zipped at the server side, to unzip it before sending it to the browser, so that the browser would know that it is not a zip-file, but an OpenOffice document. The plan is thus to have, underneath the icons, a link which invokes an application on the server (Apache module, mod_perl module, cgi-bin,..), which retrieves the zipped original, composes the appropriate HTTP headers (wich it can do only based on info stored in the db), and sends the document in the appropriate way to the browser, in the zipped format. The filename of the zipped document on the server gives no clue as to its content. Only the meta-data in the db indicates that. Thanks in advance for any insights, advice, pointers etc..
Re: Initializing Sleepycat::DbXml (Berkeley, Oracle) objects in startup.pl
Mark Hedges schrieb: *** glibc detected *** free(): invalid pointer: 0x084e6a14 *** If this didn't work in a response handler, I'd guess there's something else wrong. That's the kind of error you get when you use things under threads that are not thread-safe in some way, I remember that sort of thing trying to use List::MoreUtils::natatime() under threads. (But the rest of that library works.) It's a sad state of affairs that a large chunk of CPAN doesn't play nice with threads, and there's usually not any way of knowing which library is causing the problem. It might not even be the oracle thingy, maybe something else you're loading. It may have been XML::LibXML, XML::LibXSLT, or - most probably - my lack of understanding of the worker MPM and threaded Perl. I made some progress and got it working using package-level my-variables to cache the Berkeley handles. Still, concurrent access quite reliably manages to produce SEGVs. This may have something to do with with not finalizing the handles properly. So I think I have to use PerlChildInitHandler and PerlChildExitHandler. I spent some time wondering why the variables I initialized in the PerlChildInitHandler Eumel::A::child_init were undefined when accessed from the PerlResponseHandler Eumel::B::handler, regardless of whether they were declared with our or with my and then returned by a function. I thought that moving the child_init method into the same package as the handler and having it initialize package level my-variables or our-variables might do the trick. But it doesn't. Looks like the variables that the PerlChildInitHandler sees are different beasts than those the PerlResponseHandler sees, even though they are textually identical. Turns out under the threaded worker MPM things behave differently: | Global variables are only global to the interpreter in which | they are created. Other interpreters from other threads | can't access that variable. Though it's possible to make | existing variables shared between several threads running in | the same process by using the function | threads::shared::share(). http://perl.apache.org/docs/2.0/user/coding/coding.html#Shared_Variables Should have RTFM before. I haven't used threads to this date, nor threads::shared. Looks like I'd have to share the Berkeley handles in order for it to *maybe* work. Now here's a funny one. use threads; use threads::shared; our $env; sub child_init { share($env); $env = DbEnv-new; $env-open( $envdir, Db::DB_USE_ENVIRON | Db::DB_THREAD); print STDERR child_init: Umgebung geoeffnet\n; ... } I never see the log message - the PerlChildInitHandler thing is hanging. Which bizarrely doesn't stop the PerlResponseHandler, by the way. If I uncomment use threads, the threads::shared stuff conveniently turns into no-ops, and I get back the old behaviour, which is that the PerlChildInitHandler and the PerlResponseHandler do not see the same variables in spite of their being textually identical. I'm at my wit's end. Any clues? Michael Ludwig
Re: generic enquiry about rendering zipped content
On Fri 16 Jan 2009, André Warnier wrote: What exact form would a HTTP response need to have, for the browser to correctly interpret that the response it is getting is a document (for example an OpenOffice document or an email in eml format), but which has been zipped for transmission ? What I would like to happen is that the browser receives the zipped document, but instead of proposing to open it as a zip file or save it to disk as a zip file, unzips it and handles it properly as per the content of the zipped response. I know that this has to do with the Content-Type and Content-disposition and Content-encoding (Content-type-encoding ?) headers, but do not know exactly what are the caveats or rules or things that work with one browser and not the other kind of stuff. Does anyone know ? If more context is required : A server-side application stores on the one hand original documents of different kinds, zipped, and on the other hand meta-data about these documents in a database and search-engine. The user can search the database, and obtain a response html page, on which appear icons representing the original documents. When clicking on such an icon, the user should receive the original document. It seems a pity, considering that the document is already stored zipped at the server side, to unzip it before sending it to the browser, so that the browser would know that it is not a zip-file, but an OpenOffice document. The plan is thus to have, underneath the icons, a link which invokes an application on the server (Apache module, mod_perl module, cgi-bin,..), which retrieves the zipped original, composes the appropriate HTTP headers (wich it can do only based on info stored in the db), and sends the document in the appropriate way to the browser, in the zipped format. The filename of the zipped document on the server gives no clue as to its content. Only the meta-data in the db indicates that. Thanks in advance for any insights, advice, pointers etc.. You can send the file in DEFLATE format (rfc1951) or in GZIP format (1952). The latter happens to be the output of the gzip program. Winzip Co use a different format! I think I do something like you want to. use APR::Finfo (); use APR::Const -compile=qw/FINFO_NORM/; if( $r-finfo-filetype and $r-headers_in-{'Accept-Encoding'}=~/gzip/ and -f $r-filename.'.gz' ) { $r-filename($r-filename.'.gz'); $r-content_encoding('gzip'); $r-finfo(APR::Finfo::stat($r-filename, APR::Const::FINFO_NORM, $r-pool)); $r-headers_out-add(Vary='Accept-Encoding'); } You have to check if the browser accepts gzip format. Set the Content-Encoding header and the Vary header (for proxies). mod_negotiation (MultiViews) provides a similar functionality. Torsten -- Need professional mod_perl support? Just hire me: torsten.foert...@gmx.net
Re: Initializing Sleepycat::DbXml (Berkeley, Oracle) objects in startup.pl
What I did to get worker and event working under FreeBSD 6.3, was to eliminate the child_init handler, and at the start of the response handler do something like my $env; sub handler { # this is the response handler my ($r) = @_; if (!$env) { $env = DbEnv-new; $env-open( $envdir, Db::DB_USE_ENVIRON | Db::DB_THREAD); ... } ... } What this means is that each thread must open the db's for itself. The amount of data stored for each open DB connection, times THREADS_PER_CHILD times the number of Apache children at any given point, makes for some memory. But 1) the separate connections help the DB package be thread-safe, 2) the first-used threads keep getting re-used in preference to threads not yet used. 3) if you consider each thread as more or less equivalent to a child process in prefork, your total memory requirement is less. Guten abend (in meiner Zeitzone), cmac www.animalhead.com On Jan 16, 2009, at 11:34 AM, Michael Ludwig wrote: Mark Hedges schrieb: *** glibc detected *** free(): invalid pointer: 0x084e6a14 *** If this didn't work in a response handler, I'd guess there's something else wrong. That's the kind of error you get when you use things under threads that are not thread-safe in some way, I remember that sort of thing trying to use List::MoreUtils::natatime() under threads. (But the rest of that library works.) It's a sad state of affairs that a large chunk of CPAN doesn't play nice with threads, and there's usually not any way of knowing which library is causing the problem. It might not even be the oracle thingy, maybe something else you're loading. It may have been XML::LibXML, XML::LibXSLT, or - most probably - my lack of understanding of the worker MPM and threaded Perl. I made some progress and got it working using package-level my-variables to cache the Berkeley handles. Still, concurrent access quite reliably manages to produce SEGVs. This may have something to do with with not finalizing the handles properly. So I think I have to use PerlChildInitHandler and PerlChildExitHandler. I spent some time wondering why the variables I initialized in the PerlChildInitHandler Eumel::A::child_init were undefined when accessed from the PerlResponseHandler Eumel::B::handler, regardless of whether they were declared with our or with my and then returned by a function. I thought that moving the child_init method into the same package as the handler and having it initialize package level my-variables or our-variables might do the trick. But it doesn't. Looks like the variables that the PerlChildInitHandler sees are different beasts than those the PerlResponseHandler sees, even though they are textually identical. Turns out under the threaded worker MPM things behave differently: | Global variables are only global to the interpreter in which | they are created. Other interpreters from other threads | can't access that variable. Though it's possible to make | existing variables shared between several threads running in | the same process by using the function | threads::shared::share(). http://perl.apache.org/docs/2.0/user/coding/ coding.html#Shared_Variables Should have RTFM before. I haven't used threads to this date, nor threads::shared. Looks like I'd have to share the Berkeley handles in order for it to *maybe* work. Now here's a funny one. use threads; use threads::shared; our $env; sub child_init { share($env); $env = DbEnv-new; $env-open( $envdir, Db::DB_USE_ENVIRON | Db::DB_THREAD); print STDERR child_init: Umgebung geoeffnet\n; ... } I never see the log message - the PerlChildInitHandler thing is hanging. Which bizarrely doesn't stop the PerlResponseHandler, by the way. If I uncomment use threads, the threads::shared stuff conveniently turns into no-ops, and I get back the old behaviour, which is that the PerlChildInitHandler and the PerlResponseHandler do not see the same variables in spite of their being textually identical. I'm at my wit's end. Any clues? Michael Ludwig