PyukiWiki CVS Commit
pyuki****@lists*****
2012年 7月 31日 (火) 20:39:25 JST
Index: PyukiWiki-Devel-UTF8/lib/Nana/HTTPCompress.pm diff -u PyukiWiki-Devel-UTF8/lib/Nana/HTTPCompress.pm:1.34 PyukiWiki-Devel-UTF8/lib/Nana/HTTPCompress.pm:1.35 --- PyukiWiki-Devel-UTF8/lib/Nana/HTTPCompress.pm:1.34 Tue Jul 31 20:19:24 2012 +++ PyukiWiki-Devel-UTF8/lib/Nana/HTTPCompress.pm Tue Jul 31 20:39:25 2012 @@ -1,6 +1,6 @@ ###################################################################### # HTTPCompress.pm - This is PyukiWiki, yet another Wiki clone. -# $Id: HTTPCompress.pm,v 1.34 2012/07/31 11:19:24 papu Exp $ +# $Id: HTTPCompress.pm,v 1.35 2012/07/31 11:39:25 papu Exp $ # # "Nana::HTTPCompress" ver 0.2 $$ # Author: Nanami @@ -26,7 +26,7 @@ use Nana::ServerInfo; ###################################################################### -# http://www.submit.ne.jp/1500 +# multicore gzip tips: http://www.submit.ne.jp/1500 $gzip::path; $gzip::header; @@ -34,6 +34,7 @@ sub init { my($path)=@_; my $info=new Nana::ServerInfo; + my $pigz_command='pigz'; my $gzip_command='gzip'; my $execpath="/usr/local/bin:/usr/bin:/bin:$ENV{PATH}"; @@ -44,8 +45,8 @@ my $forceflag=""; my $fastflag=""; foreach(split(/:/,$execpath)) { - if(-x "$_/$pigz_command" && $info->val("core") > 3) { - $path="$_/$pigz_command" ; + if(-x "$_/$gzip_command") { + $path="$_/$gzip_command" ; if(open(PIPE,"$path --help 2>&1|")) { foreach(<PIPE>) { $forceflag="--force" if(/(\-\-force)/); @@ -54,9 +55,10 @@ close(PIPE); } } - - if(-x "$_/$gzip_command") { - $path="$_/$gzip_command" ; + } + foreach(split(/:/,$execpath)) { + if(-x "$_/$pigz_command" && $info->core > 3) { + $path="$_/$pigz_command" ; if(open(PIPE,"$path --help 2>&1|")) { foreach(<PIPE>) { $forceflag="--force" if(/(\-\-force)/); Index: PyukiWiki-Devel-UTF8/lib/Nana/ServerInfo.pm diff -u PyukiWiki-Devel-UTF8/lib/Nana/ServerInfo.pm:1.1 PyukiWiki-Devel-UTF8/lib/Nana/ServerInfo.pm:1.2 --- PyukiWiki-Devel-UTF8/lib/Nana/ServerInfo.pm:1.1 Tue Jul 31 20:19:24 2012 +++ PyukiWiki-Devel-UTF8/lib/Nana/ServerInfo.pm Tue Jul 31 20:39:25 2012 @@ -1,6 +1,6 @@ ###################################################################### # ServerInfo.pm - This is PyukiWiki, yet another Wiki clone. -# $Id: ServerInfo.pm,v 1.1 2012/07/31 11:19:24 papu Exp $ +# $Id: ServerInfo.pm,v 1.2 2012/07/31 11:39:25 papu Exp $ # # "Nana::ServerInfo" ver 0.1 $$ # Author: Nanami @@ -39,7 +39,7 @@ close(PIPE); } if(lc $os eq "freebsd") { - open(PIPE, "cat /var/run/dmesg.boot |") || die; + open(PIPE, "/bin/cat /var/run/dmesg.boot |") || die; foreach(<PIPE>) { $info.=$_; } @@ -53,22 +53,29 @@ $cores=$lines if($lines > 1); } if(lc $os eq "freebsd") { - my $buf=$info; - $buf=~s/[\r\n]//g; - $buf=~s/.*\: //g; - $buf=~s/ CPUs//g; - $cores=$buf if($buf+0 > 1); + foreach my $buf(split/\n/,$info) { + if($buf=~/ CPUs/) { + $buf=~s/.*\: //g; + $buf=~s/ CPUs//g; + $cores=$buf if($buf+0 > 1); + } + } } my $self={ os=>$os, - core=>$cores + core=>$cores + 0 }; return bless $self, $class; } -sub val { +sub os { + my($self,$name)=@_; + return $self->{os} +} + +sub core { my($self,$name)=@_; - return $self->$name; + return $self->{core}; } 1;