Re: Flakey [Named]VirtualHost support, should TieHash be used?
I'd just like to say that YOU ROCK! I was using push the wrong way originally, by trying to push a hash unto an array. This way works like a charm. Got rid of the "Attempt to free unreferenced scalar." errors and the instability. Thanks Ben! Alex Alexey Zilber Director of MIS CCG.XM 498 Seventh Ave, 16th Fl New York, New York, 10018 tel 212.297.7048 fax 212.297.8939 email [EMAIL PROTECTED] >>> Benjamin Trott <[EMAIL PROTECTED]> 11/8/00 5:25:32 PM >>> > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. Interesting. Is the number of "Attempt to free unreferenced scalar." messages the same as the number of undef elements in @VirtualHost? >> Where you write $#VirtualHost, that's the *array* @VirtualHost; it's not the >> number of elements in @{ $VirtualHost{$ip} }. See the difference? Each time >> you increment $#VirtualHost, you > > ... got cut off.. I increment the array not the elements?? Oops, sorry. I was going to say that when you increment $#VirtualHost, you increase the size of the array @VirtualHost, adding a new (undefined) element. In other words you're using an array as a glorified index counter. :) bye, Ben
Re: Flakey [Named]VirtualHost support, should TieHash be used?
> Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. > Attempt to free unreferenced scalar. Interesting. Is the number of "Attempt to free unreferenced scalar." messages the same as the number of undef elements in @VirtualHost? >> Where you write $#VirtualHost, that's the *array* @VirtualHost; it's not the >> number of elements in @{ $VirtualHost{$ip} }. See the difference? Each time >> you increment $#VirtualHost, you > > ... got cut off.. I increment the array not the elements?? Oops, sorry. I was going to say that when you increment $#VirtualHost, you increase the size of the array @VirtualHost, adding a new (undefined) element. In other words you're using an array as a glorified index counter. :) bye, Ben
Re: Flakey [Named]VirtualHost support, should TieHash be used?
Benjamin Trott <[EMAIL PROTECTED]> 11/8/00 4:23:12 PM >>> >> For some reason I usually >> need to start Apache 4-5 times before it actually "sticks" and starts. > >What do you mean by "sticks"? You mean, when it doesn't "work", Apache isn't running? Exactly. It says httpd started but, form what I cant tell, it starts up really quickly, then exits. > What happens when you do httpd -S (should show the configured virtual > hosts)? Show's everything correctly, but it also shows: Attempt to free unreferenced scalar. Attempt to free unreferenced scalar. Attempt to free unreferenced scalar. Attempt to free unreferenced scalar. Attempt to free unreferenced scalar. Right before the VirtualHost configuration. I just noticed that when it gives ~16 of those lines, apache won't start. Less, it starts fine... >> One other weirdness.. when I startup Apache, I get a bunch of "unreferenced >> and undefined" warnings. Those are evident in the ServerConfig.pm below. > You mean the @VirtualHost = ( undef, undef, ... ) stuff? Yes, that bothers me. >This is because of the following line: > >> $VirtualHost{$ip}[++$#VirtualHost] = { > >Where you write $#VirtualHost, that's the *array* @VirtualHost; it's not the >number of elements in @{ $VirtualHost{$ip} }. See the difference? Each time >you increment $#VirtualHost, you ... got cut off.. I increment the array not the elements?? >It'd be possible to get the number of elements in @{ $VirtualHost{$ip} } and >increment that etc. But why not just use push? > > push @{ $VirtualHost{$ip} }, { ... }; > >Much easier, yes? > >Same thing here: > >> $NameVirtualHost[++$#NameVirtualHost] = $ip; > >push @NameVirtualHost, $ip; Hmmm, something doesn't make sense here. I originally used push, but the previous data got overwritten. I'll try it again tonight and report back.. Thank you! Alexey Zilber Director of MIS CCG.XM 498 Seventh Ave, 16th Fl New York, New York, 10018 tel 212.297.7048 fax 212.297.8939 email [EMAIL PROTECTED]
Re: Flakey [Named]VirtualHost support, should TieHash be used?
> For some reason I usually > need to start Apache 4-5 times before it actually "sticks" and starts. What do you mean by "sticks"? You mean, when it doesn't "work", Apache isn't running? What happens when you do httpd -S (should show the configured virtual hosts)? > One other weirdness.. when I startup Apache, I get a bunch of "unreferenced > and undefined" warnings. Those are evident in the ServerConfig.pm below. You mean the @VirtualHost = ( undef, undef, ... ) stuff? This is because of the following line: > $VirtualHost{$ip}[++$#VirtualHost] = { Where you write $#VirtualHost, that's the *array* @VirtualHost; it's not the number of elements in @{ $VirtualHost{$ip} }. See the difference? Each time you increment $#VirtualHost, you It'd be possible to get the number of elements in @{ $VirtualHost{$ip} } and increment that etc. But why not just use push? push @{ $VirtualHost{$ip} }, { ... }; Much easier, yes? Same thing here: > $NameVirtualHost[++$#NameVirtualHost] = $ip; push @NameVirtualHost, $ip; bye, Benjamin Trott
Flakey [Named]VirtualHost support, should TieHash be used?
Hi All, I've been developing a little mod_perl Apache::Registery script that builds VirtualHosts and NamedVirtualhost's based on pre-generated text files. The code works wonderfully... when it actually works. For some reason I usually need to start Apache 4-5 times before it actually "sticks" and starts. There are no error messages, no cores/segfaults, just a usualy httpd started. I've read about using TieHash in the O'Reilly book, but I'm hazy on implementing it, so I haven't. My gut feeling is that that is the problem. If someone would look at the code and tell me wtf is going wrong... BTW: this is my first Apache::Registry proggie. What it does, is read in a text file (.domains) that's in the following format: ::: And for subsequent namevirtualhosts : One other weirdness.. when I startup Apache, I get a bunch of "unreferenced and undefined" warnings. Those are evident in the ServerConfig.pm below. IF this is a TiexHash issue, could someone show me a good example of using it with the following code? Thanks! Alex Brace yourselves (from httpd.conf): - #!perl use Apache::PerlSections(); my $clientdir = "/home/clients"; my $sslclientdir = "/home/clients-ssl"; my $logdir = "/data/logs"; my $ssllogdir = "/data/logs-ssl"; my $domainfile = "$clientdir" . "/" . ".domains"; open DOMAINS, "$domainfile" || die "Cannot open $domainfile!"; my @maindoms; my $line; while($line=){ chomp($line); if($line){ push @maindoms,$line; } } close DOMAINS; my $locuser; my $crap; my $ip; my $domain; my $port; foreach my $toplvl(@maindoms){ ($ip,$domain,$port,$crap) = split(":",$toplvl,4); ($locuser,$crap) = split(/\./,$domain,2); print STDERR "foreach: $ip:$domain:$port with user+group: $locuser [$crap]\n"; if($port eq "80"){ print STDERR "foreach: port = 80\n"; unless (-d "$logdir/$domain"){ mkdir "$logdir/$domain", 0755; print STDERR "foreach: mkdir: $logdir/$domain\n"; } unless (-d "$clientdir/$domain"){ my $line="cp -Rf /home/defaults/ $clientdir/$domain/"; mkdir "$clientdir/$domain", 0755; require File::NCopy; File::NCopy::copy("/home/defaults/*","$clientdir/$domain"); File::NCopy::copy("/home/defaults/.*","$clientdir/$domain"); print STDERR "foreach: cp: $clientdir/$domain\n"; } # chown -R "$uid:$gid" "$clientdir/$domain"; } elsif($port eq "443"){ print STDERR "foreach: port = 443\n"; unless (-d "$ssllogdir/$domain"){ mkdir "$ssllogdir/$domain", 0755; print STDERR "foreach: mkdir: $ssllogdir/$domain\n"; } unless (-d "$sslclientdir/$domain"){ my $line="cp -Rf /home/defaults/ $sslclientdir/$domain/"; #system($line); mkdir "$sslclientdir/$domain", 0755; require File::NCopy; File::NCopy::copy("/home/defaults/*","$sslclientdir/$domain"); print STDERR "foreach: cp: $sslclientdir/$domain\n"; # chown -R "$uid:$gid" "$clientdir/$domain"; } } else { print STDERR "No port specified in domains file!\n"; } print STDERR "Building Virtual Host for $domain at $ip\n"; $NameVirtualHost[++$#NameVirtualHost] = $ip; $VirtualHost{$ip}[++$#VirtualHost] = { ServerName => "$domain", ServerAdmin => "webmaster\@$domain", ServerAlias => "www.$domain", DocumentRoot => "$clientdir/$domain", CustomLog => "$logdir/$domain/access_log combined", ErrorLog => "$clientdir/$domain/error_log", Directory => { "$clientdir/$domain" => { Options => 'All ExecCGI', AllowOverride => 'All', }, "$clientdir/$domain/cgi-bin" => { AllowOverride => 'None', Options => 'ExecCGI', SetHandler => 'cgi-script', }, }, ScriptAlias => "/cgi-bin/ $clientdir/$domain/cgi-bin/", }; #End VirtualHost print STDERR "VirtualHost $ip\n"; if(-f "$clientdir/$domain/.domains"){ open PIGGY, "$clientdir/$domain/.domains" || die "Weird piggy error."; my $pline; my $lcrap; my @piggys; $