vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r16103: use LJ::Request instead of Apache(->requ...

Committer: vsukhanov
use LJ::Request instead of Apache(->request)
U   branches/modernize2/cgi-bin/Apache/SendStats.pm
U   branches/modernize2/cgi-bin/LJ/Request/Apache.pm
Modified: branches/modernize2/cgi-bin/Apache/SendStats.pm
===================================================================
--- branches/modernize2/cgi-bin/Apache/SendStats.pm	2010-01-19 08:43:34 UTC (rev 16102)
+++ branches/modernize2/cgi-bin/Apache/SendStats.pm	2010-01-19 09:39:15 UTC (rev 16103)
@@ -16,11 +16,10 @@
 
 sub handler
 {
-    my $r = shift;
-    return OK if $r->main;
+    return OK if LJ::Request->main;
     return OK unless $LJ::HAVE_AVAIL && $LJ::FREECHILDREN_BCAST;
 
-    my $callback = $r ? $r->current_callback() : '';
+    my $callback = LJ::Request->is_inited ? LJ::Request->current_callback() : '';
     my $cleanup = $callback eq "PerlCleanupHandler";
     my $childinit = $callback eq "PerlChildInitHandler";
 
@@ -30,7 +29,7 @@
         if ($cleanup) {
             LJ::MemCache::delete($key);
         } else {
-            LJ::MemCache::set($key, $r->header_in("Host") . $r->uri . "(" . $r->method . "/" . scalar($r->args) . ")");
+            LJ::MemCache::set($key, LJ::Request->header_in("Host") . LJ::Request->uri . "(" . LJ::Request->method . "/" . scalar(LJ::Request->get_params) . ")");
           }
     }
 
@@ -54,7 +53,7 @@
                 $sock->sockopt(SO_BROADCAST, 1)
                     if $LJ::SENDSTATS_BCAST;
             } else {
-                $r->log_error("SendStats: couldn't create socket: $host");
+                LJ::Request->log_error("SendStats: couldn't create socket: $host");
                 next;
             }
         }
@@ -63,7 +62,7 @@
         my $portaddr = sockaddr_in($port, $ipaddr);
         my $message = "bcast_ver=1\nfree=$free\nactive=$active\n";
         my $res = $sock->send($message, 0, $portaddr);
-        $r->log_error("SendStats: couldn't broadcast")
+        LJ::Request->log_error("SendStats: couldn't broadcast")
             unless $res;
     }
 

Modified: branches/modernize2/cgi-bin/LJ/Request/Apache.pm
===================================================================
--- branches/modernize2/cgi-bin/LJ/Request/Apache.pm	2010-01-19 08:43:34 UTC (rev 16102)
+++ branches/modernize2/cgi-bin/LJ/Request/Apache.pm	2010-01-19 09:39:15 UTC (rev 16103)
@@ -74,6 +74,12 @@
     return $instance->{r}->is_main(@_);
 }
 
+sub LJ::Request::main {
+    my $class = shift;
+    die "Request is not provided to LJ::Request" unless $instance;
+    return $instance->{r}->main(@_);
+}
+
 sub LJ::Request::dir_config {
     my $class = shift;
     die "Request is not provided to LJ::Request" unless $instance;
@@ -149,12 +155,12 @@
 
 sub LJ::Request::set_handlers {
     my $class = shift;
-    $instance->{apr}->set_handlers(@_);
+    $instance->{r}->set_handlers(@_);
 }
 
 sub LJ::Request::handler {
     my $class = shift;
-    $instance->{apr}->handler(@_);
+    $instance->{r}->handler(@_);
 }
 
 sub LJ::Request::method_number {
@@ -167,6 +173,11 @@
     return $instance->{r}->status(@_);
 }
 
+sub LJ::Request::status_line {
+    my $class = shift;
+    return $instance->{r}->status_line(@_);
+}
+
 ##
 ##
 ##
@@ -326,6 +337,11 @@
     return 1;
 }
 
+sub LJ::Request::unset_headers_in {
+    my $class = shift;
+    my $header = shift;
+    $instance->{r}->headers_in->unset($header);
+}
 
 sub LJ::Request::log_error {
     my $class = shift;
@@ -363,5 +379,20 @@
 
 }
 
+sub LJ::Request::parsed_uri {
+    my $class = shift;
+    $instance->{r}->parsed_uri; # Apache::URI
+}
 
+sub LJ::Request::current_callback {
+    my $class = shift;
+    return $instance->{r}->current_callback;
+}
+
+sub LJ::Request::child_terminate {
+    my $class = shift;
+    return $instance->{r}->child_terminate;
+}
+
+
 1;

Tags: livejournal, pm, vadvs
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments