Re: What's wrong with this?
On Sun, Jan 02, 2000 at 01:13:26PM -0800, Aaron Turner wrote: This is driving me nuts. This code works the first few exectutions, but then doesn't after a while. It's pretty simple, it should print out: Name = value1 Name = value2 then after a few reloads it prints: Name = value1 Name = value1 I'm sure it's something stupid, but my brain is apparently fried. This is a FAQ. You're declaring a closure by using %variable in that inside subroutine. Yes, it's 'my' to the handler, but using it inside the other subroutine makes it kind of like a persistent copy of the very first usage of the variable. So, even if the handler gets a new %variable each time, the closure never sees it. That's the behavior you're seeing, per apache process. That's right. But actually this is not a closure but a nested subroutine effect. I've erroneously called this effect a closure in the guide, I've fixed it now (see perl.apache.org/guide/perl.html). But the implications are correct. % perldoc -q closure =head1 Found in /usr/lib/perl5/5.00503/pod/perlfaq7.pod =head2 What's a closure? Closures are documented in Lperlref. IClosure is a computer science term with a precise but hard-to-explain meaning. Closures are implemented in Perl as anonymous subroutines with lasting references to lexical variables outside their own scopes. These lexicals magically refer to the variables that were around when the subroutine was defined (deep binding). Closures make sense in any programming language where you can have the return value of a function be itself a function, as you can in Perl. Note that some languages provide anonymous functions but are not capable of providing proper closures; the Python language, for example. For more information on closures, check out any textbook on functional programming. Scheme is a language that not only supports but encourages closures. ... the FAQ section is continued ___ Stas Bekmanmailto:[EMAIL PROTECTED] http://www.stason.org/stas Perl,CGI,Apache,Linux,Web,Java,PC http://www.stason.org/stas/TULARC perl.apache.orgmodperl.sourcegarden.org perlmonth.comperl.org single o- + single o-+ = singlesheavenhttp://www.singlesheaven.com
Attempt to free unreferenced scalar (again)
I looked at the archive, and noticed Doug's patch in perl_conf.c: http://www.geocrawler.com/archives/3/182/1999/7/0/2414262/ -hv_store(nhv, (char*)key, klen, rv, FALSE); +hv_store(nhv, (char*)key, klen, SvREFCNT_inc(rv), FALSE); As far as I can tell (from finding perl_conf.c on this machine) it already has this patch. Running Apache 1.3.9 and, I think*, mod_perl-1.21. Perl is 5.005 and Sun 2.6. I'm not running Apache::StatINC, but PerlFreshRestart is on. Although mod_perl looks statically linked, Apache does have DSO support, and mod_rewrite is pulled in this way. * I didn't build the production Apache where the error is showing up. I did build the Apache where I was testing and I didn't see the error. The sparse and infrequent error message makes this hard to track down. Any suggestions on how I can narrow down where to look? Thanks, Bill Moseley mailto:[EMAIL PROTECTED]
Re: Attempt to free unreferenced scalar (again)
On Tue, 04 Jan 2000, Bill Moseley wrote: I looked at the archive, and noticed Doug's patch in perl_conf.c: http://www.geocrawler.com/archives/3/182/1999/7/0/2414262/ -hv_store(nhv, (char*)key, klen, rv, FALSE); +hv_store(nhv, (char*)key, klen, SvREFCNT_inc(rv), FALSE); As far as I can tell (from finding perl_conf.c on this machine) it already has this patch. Running Apache 1.3.9 and, I think*, mod_perl-1.21. Perl is 5.005 and Sun 2.6. I'm not running Apache::StatINC, but PerlFreshRestart ^ Can you be more specific. Sometimes these ATFUS bugs are perl bugs, so it's worth giving the full perl version info. -- Matt/ Details: FastNet Software Ltd - XML, Perl, Databases. Tagline: High Performance Web Solutions Web Sites: http://come.to/fastnet http://sergeant.org Available for Consultancy, Contracts and Training.
Re: Attempt to free unreferenced scalar (again)
At 04:47 PM 1/4/00 +, Matt Sergeant wrote: As far as I can tell (from finding perl_conf.c on this machine) it already has this patch. Running Apache 1.3.9 and, I think*, mod_perl-1.21. Perl is 5.005 and Sun 2.6. I'm not running Apache::StatINC, but PerlFreshRestart ^ That is the full version. Bill Moseley mailto:[EMAIL PROTECTED]
Re: Attempt to free unreferenced scalar (again)
Here's perl -V (Sorry Matt for emailing you directly. I wish the list used a Reply-To: to the list so replying wouldn't default to the individual.) 115) ~/apache %/usr/local/bin/perl5.005 -V Summary of my perl5 (5.0 patchlevel 5 subversion 0) configuration: Platform: osname=solaris, osvers=2.5.1, archname=sun4-solaris uname='sunos sunsite 5.5.1 generic sun4d sparc sunw,sparccenter-2000 ' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='gcc', optimize='-O', gccversion=2.7.0 cppflags='' ccflags ='' stdchar='unsigned char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc -lcrypt libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib' Characteristics of this binary (from libperl): Built under solaris Compiled at Sep 14 1998 15:45:04 %ENV: PERLLIB="/data/_g/lii/perl_lib/lib/site_perl/5.005:/data/_g/lii/perl_lib/lib /site_perl/5.005/sun4-solaris" @INC: /data/_g/lii/perl_lib/lib/site_perl/5.005 /data/_g/lii/perl_lib/lib/site_perl/5.005/sun4-solaris /usr/local/perl5.005/lib/5.005/sun4-solaris /usr/local/perl5.005/lib/5.005 /usr/local/perl5.005/lib/site_perl/5.005/sun4-solaris /usr/local/perl5.005/lib/site_perl/5.005 . Bill Moseley mailto:[EMAIL PROTECTED]
RE: Modules Lost in EMBPERL
sub new { my $pkg = shift; my $fdatref = shift; my $database = 'patients'; my $obj = bless { '_fdatref' = $fdatref, '_balances' = 0, ## array ref for balances '_prev_patnums' = 0, ## array ref for prev_patnums '_dbh' = SQLHANDLE-allocate($database) }, $pkg; return $obj; } One problem could be, if SQLHANDLE-allocate dies (e.g. in getdbh), then your object will never returned and will be undef in further [- -] blocks You can wrap your constructor in an eval { } to catch this case. Yes. In order to spare you too much code, I forgot to mention that we have rewritten the code to be [- use FINANCEMOD -] and this fails to take in the module. It ends with a return 1 statement. I run into this often. this is converted by Embperl internaly to $x = eval { sub { use FINANCEMOD ; } } ; I have seen this problem seen before, seems like Perl requires the semicolon in this case. From point of scoping [- -] is wrapped in an Perl { } block, Does that mean the entire pages embperl is evaluated together as one eval? each [- -] is evaled as a separate anoymous sub, if there are any [* *] blocks they are evaled in one sub together, which calls the other subs, but this are the current implementation details, which may change in the future (e.g. in Embperl 2.0). Anyway I will make sure that scoping remains the same. We call a CGI from modules from EMBPERL all under mod_perl. When we run into this bug, it seems to happen after [$ $] if or whiles or foreaches. I've also wondered about $escmod - it might be adding to the trouble as we are changing it from section to selection. This shouldn't be a problem. Gerald
Apache::Session::DBI on Solaris 2.6 woes
Hi there, For the last 2 months, I've been using Apache::Session::DBI on a Solaris 2.6 box (with the semaphorelocker nsems value set to 16) to store session information on a busy web site. Unfortunately, things seem to have gone awry, specifically with the tie: tie %SESSION, 'Apache::Session::DBI', $cookie, { DataSource = 'DBI:mysql:mydatabase', UserName = 'user', Password = 'pass' }; The connection to the database ties up a mySQL thread, and each time a session tie is called, the httpd daemon handling the request doesn't let go, so the mysql thread table gradually fills up to the maximum limit set. (Sorry for the horrible grammar) All other database connections for the site seem to work as normal. I'm running Apache 1.3.9, mod_perl 1.21, Apache::Session 1.03 and DBI 1.13. I've seen similar behaviour before when the tie to %SESSION was predeclared with "use vars qw /%SESSION/" rather than "my". I'm at a complete loss as to what might be going on, especially in the light of the development Linux box (running the same versions of everything as the Solaris box) working perfectly well. Does anyone have any ideas as to what might be wrong? Many thanks, Chris
Apache::AuthzDBI giving me grief
Apache 1.3.9 - Linux RH 6.1 - mod_perl 1.21 I constantly see a number of recurring errors in my log file as follows: [Tue Jan 4 15:07:30 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116. There seems to be no consistency with this error occuring and I don't know even where to begin to look for a possible solution...the result of this error is occasionally when someone attempts to access a page inside the protected area...the .htaccess file spews out an Internal Server error...as stated earlier I can't purposely recreate it just appears to happen at random. Any ideas or suggestions on how to track down the problem would be greatly appreciated. Sincerely, Craig Vincent
Re: Apache::AuthzDBI giving me grief
what version of ApacheDBI do you use ? can you send me the relevant part of the error_log ? I'm using 0.86 of Apache::AuthzDBI And using 0.87 Apache::DBI There really isn't any other relevant part of the log...the only errors I see is [Tue Jan 4 15:52:53 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116, file chunk 96. [Tue Jan 4 15:52:54 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116. [Tue Jan 4 15:52:54 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116. [Tue Jan 4 15:52:54 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/SSI.pm line 26. [Tue Jan 4 15:52:54 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/SSI.pm line 104, GEN21 chunk 1. [Tue Jan 4 15:52:54 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116. Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116. [Tue Jan 4 15:52:55 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116, file chunk 96. [Tue Jan 4 15:52:55 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116. [Tue Jan 4 15:52:55 2000] null: Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/Apache/AuthzDBI.pm line 116, file chunk 96. And because there's no IPs or other identification information provided it's impossible for me to match the access logs up with anything. Any ideas? Sincerely, Craig Vincent
Re: Apache::AuthzDBI giving me grief
1) try upgrading to a current version of Apache::DBI - Apache::AuthzDBI was replaced by Apache::AuthDBI in 0.84 Actually that seems to have solved my problem :) The mod_perl documentation I have talks about using AuthzDBI and AuthenDBI for database authenticationonce I looked up the info on AuthDBI and reconfigured everything to use that instead the errors ceased. I appreciate everyone's help in this matter...such a simple problem but I could have spent days looking for a solution before realizing the modules themselves were obsolete. *thx* Sincerely, Craig Vincent
Re: Apache::AuthzDBI giving me grief
Craig Vincent wrote: what version of ApacheDBI do you use ? can you send me the relevant part of the error_log ? I'm using 0.86 of Apache::AuthzDBI And using 0.87 Apache::DBI strange, since 0.84 the two modules AuthzDBI and AuthenDBI have been combined into one module AuthDBI. So which one do you use ? Edmund -- Edmund Mergl mailto:[EMAIL PROTECTED] http://www.bawue.de/~mergl
Tieing $q to $r
Trying to tie $q to $r so I can just pass around a single variable to subs. Not working too well... Getting frustrated... Getting ready to punch computer... :) using Registry: my($r) = Apache-request; my($q) = new CGI::Apache; $r-notes('q',$q); test($r); sub test { my($r) = shift; my($q) = $r-notes('q'); print $q-param('test'); } I'm trying to pass my $q in a fashion like the above example, but can't get it to work. If anyone has any insights or can provide some help, I'd really appreciate it. I've tried sending it as a reference, and all (ie: $r-notes('q',\$q))...Can't get it. Arthur
Re: Tieing $q to $r
I don't think that the my($r) is going to work out too well here. I don't use apache registry but I don't think you want to freeze the Apache-request and CGI::Apache objects to what they are when the program is compiled. These usually need to be modified by apache for each request. check out: http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S cliff rayman genwax.com "Arthur M. Kang" wrote: Trying to tie $q to $r so I can just pass around a single variable to subs. Not working too well... Getting frustrated... Getting ready to punch computer... :) using Registry: my($r) = Apache-request; my($q) = new CGI::Apache; $r-notes('q',$q); test($r); sub test { my($r) = shift; my($q) = $r-notes('q'); print $q-param('test'); } I'm trying to pass my $q in a fashion like the above example, but can't get it to work. If anyone has any insights or can provide some help, I'd really appreciate it. I've tried sending it as a reference, and all (ie: $r-notes('q',\$q))...Can't get it. Arthur