[mp2] mod_perl2 + XML::LibXML = OK ?
Hi, Are there any problems using XML::LibXML and XML::LibXSLT with mod_perl 2 (perl 5.8)? (everything is the latest versions as grabbed from Randy's site ;) win32). My primary concern is thread-safety (is XML::LibXML thread-safe?), but anything I should be aware about would be nice to know. Thanks, -Kurt. __ kurt george gjerde <[EMAIL PROTECTED]> intermedia uib, university of bergen I don't work here.
Help: Can't coerce GLOB to string...
Hi, I get a "Can't coerce GLOB to string"-error for every new thread that is started (mp2). I have no idea why this happens (or even what this error actually means). The module is included below (line producing the error is marked "ERROR HERE"). Error happens for every new thread (on the first request). When running ApacheBench ab -c 3 -n 100 http://... I get 3 errors and 97 OKs. Very grateful if anyone care to look at this! [Apache/2.0.43 (Win32) mod_perl/1.99_09-dev Perl/v5.8.0 DAV/2] -- Here's the module -- package MyApache::XSLTransformer; use strict; use warnings FATAL=>'all', NONFATAL=>'redefine'; use Apache::RequestRec (); use Apache::RequestIO (); use Apache::Const -compile => qw(OK); use threads; use threads::shared; use XML::LibXML; use XML::LibXSLT; use APR::OS; my $statRequestCount = 0; my $statErrorCount = 0; sub handler { my $r = shift; $statRequestCount++; $r->content_type('text/html'); my $documentFilename = $ENV{SCRIPT_FILENAME}; my $stylesheetFilename = $r->dir_config("xslTransformer_stylesheet"); return 404 unless -e $documentFilename; my $xmlParser = XML::LibXML->new(); my $xsltParser = XML::LibXSLT->new(); ### PARSE DOCUMENT my $document; eval { $document = $xmlParser->parse_file($documentFilename); }; if ($@) { return error($r,'Error parsing XML document',$@); } ### PARSE STYLESHEET DOCUMENT my $stylesheetDocument; eval { $stylesheetDocument = $xmlParser->parse_file($stylesheetFilename); }; if ($@) { return error($r,'Error parsing XSL stylesheet document (XML)',$@); } ### PARSE STYLESHEET my $stylesheet; eval { $stylesheet = $xsltParser->parse_stylesheet($stylesheetDocument); }; if ($@) { return error($r,'Error parsing XSL stylesheet (XSLT)',$@); } ### TRANSFORM my $results; eval { $results = $stylesheet->transform($document); ### <--- ERROR HERE }; if ($@) { return error($r,'Error transforming document',$@); } ### PRINT eval { print $stylesheet->output_string($results); }; if ($@) { return error($r,'Error serializing transformed document',$@); } my $tid = APR::OS::thread_current(); $r->log_error("[xslTransformer] OK [tid=$tid|reqno=$statRequestCount|errno=$statErrorCount]"); return Apache::OK; } sub error { my ($r,$title,$msg) = @_; $statErrorCount++; my $tid = APR::OS::thread_current(); $r->log_error("[xslTransformer] $title - $msg [tid=$tid|reqno=$statRequestCount|errno=$statErrorCount]"); return 500; } 1; --- The exact error log entry is: --- [Tue Feb 25 16:04:04 2003] [error] [xslTransformer] Error transforming document - Can't coerce GLOB to string in entersub at E:/data/www/perlLib/MyApache/XSLTransformer.pm line 74. [tid=APR::OS::Thread=SCALAR(0x1205be4)|reqno=1|errno=1] Thanks, -Kurt. __ kurt george gjerde <[EMAIL PROTECTED]> intermedia uib, university of bergen Working for bandwidth.
Re: Help: Can't coerce GLOB to string...
On Wed, 26 Feb 2003, Stas Bekman wrote: > > use threads; > > use threads::shared; > > why do you need to load threads? Do you plan to spawn your own threads? No, they're not supposed to be there. > > ### TRANSFORM > > my $results; > > eval { > > $results = $stylesheet->transform($document); ### <--- ERROR HERE > > It's expecting a scalar as an argument, right? could it be that $document is > not a scalar? try to print ref($document)? It's expecting an XML::LibXML::Document which is a blessed scalar, yes. And that's what it gets. I've also done some further tests now and all objects ($document, $stylesheet, etc) are identical for ok'ed and failed requests. Also, I've found that not all threads fail on the first request (but most do) and, older requests may fail as well... I've also tried adding the following to httpd.conf: PerlInterpMaxRequests 10 PerlInterpStart 1 PerlInterpMax 1 This would limit the number of threads to 1, right? Well, it doesn't. Multiple threads are still being created. I'll post this to the dev list. There isn't a bugzilla or something for the mp2, is there? thanks, -Kurt. __ kurt george gjerde <[EMAIL PROTECTED]> intermedia uib, university of bergen Will work for money.
[mp2] Post-request operations
Hi, In mod_perl 2 under MPM (win32), is there a way of returning the request to the client (browser) and having the script continue doing other (time consuming) operations (without the client having to wait). Under mp1/linux I guess I could fork but how can I do this on win32? A typical example could be to receive a file upload, return OK to the client, and then convert the file to some other format(s). thanks, -Kurt. __ kurt george gjerde <[EMAIL PROTECTED]> intermedia uib, university of bergen
Re: Help: Can't coerce GLOB to string...
Ah, an old message of mine. I think this in the end boiled down to mod_perl writing this particular error to the server's main error_log and not to the actual virtual server's error_log where other errors go. This might have been fixed. I still run the same build of mp2 (because it works) but I guess I should upgrade :) Thanks, -Kurt. Stas Bekman wrote: [Forwarded from "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>] Hello, In response to : Kurt George Gjerde wrote: > BTW: I've fixed my "can't coerce GLOB to string" problem I had last week. > Was unrelated to mod_perl (sorry). It seems XML::LibXSLT produced some > errors which went straight to STDERR. Under CGI these ends up in the > error_log but under mod_perl it seems STDERR is just a black hole (?). > Would it be possible to map STDERR to log_error()? Unless I'm missing something, mod_perl doesn't do anything special with STDERR (it does tie STDIN and STDOUT for 'perl-script' handlers). Apache opens stderr to error_log, and then everything just works. e.g. if you do: warn "Foo"; or print STDERR "OOOPS\n"; this ends up in error_log, no? I suppose that XML::LibXSLT redefines STDERR then. Try to see what it does to create this problem. The key to this problem is that the function $parser->parse_string() cannot take a scalar as argument. This way it works and doesn't produce "Can't coerce ..." anymore : my $sheet = $parser->parse_string(<<'EOT'); http://www.w3.org/1999/XSL/Transform"; version="1.0"> ... EOT Best regards Jean Philippe GUILLEMIN http://shweps.free.fr [EMAIL PROTECTED]
Apache growing (memory)
Hi, I recently discovered the following on an Apache/mod_perl server. I have Apache for win32, ActiveState's Perl and the mod_perl PPM installed (on a Windows 2000 Pro OS, but read on anyway ;). All were downloaded and installed last week so they are the latest versions. Each time a page is downloaded the Apache service process claims more memory. Well, not each time but like for every 20th download the task manager shows Apache using 20-30K more... A test showed that reloading the same page 2000 times raised Apaches memory by approx 1000k. At first I thought that this was due to some sloppy programming (of mine) in my recent mod_perl handler, but not so. When using an empty handler (just the handler sub shell without any code inside it) the same thing occurred. This does not happen when loading non-script files (plain html). Then I did the same test on an ordinary CGI Perl script (no mod_perl) and the same thing happened then as well (so why am I posting this here?!). Since this is on win32 Apache will continue using the same (sub-)process until it's restarted (unlike Unix; though it IS possible to set up a 'retirement plan' on win32 as well). My fear is that Apache will end up using all the RAM... Does anyone know why this is happening? Is it the win32 build of Apache or does this happen on other platforms also? Thanks, -Kurt. ______ kurt george gjerde <[EMAIL PROTECTED]> dept. of media studies, university of bergen
Is mod_perl on win32 possible??
Hi again (and thanks to everyone who replied to my last post). Is it at all possible to get mod_perl to work PROPERLY on win32? Using multi-threading? Since win32 can't fork, Apache here uses multi-threading. This actually works very well... except for mod_perl which doesn't use multi-threading itself. This means that if one page takes a long time to deliver, all other requests will have to wait in line! ...making mod_perl unusable. Is it possible to create a multi-threaded mod_perl handler or won't this help? Or does there exist binaries of Apache for win32 that use forking? Or do I have to set up a linus/bsd server... :) thanks, -Kurt.