]> source.dussan.org Git - rspamd.git/commitdiff
Store partial results in memcached.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 16 Jun 2015 18:09:36 +0000 (19:09 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 16 Jun 2015 18:09:36 +0000 (19:09 +0100)
utils/redirector.pl.in

index 704f5749b2775af22d48311ccce19818bfa56582..b483c127f46cf1f72a4190111583d943a12dff10 100755 (executable)
@@ -203,7 +203,9 @@ sub memcached_cache_url {
        if ( $url ne $url_real ) {
                my $context = Digest->new("SHA-256");
                $context->add($url);
-               $memd->set( $context->digest(), $url_real, $cfg{cache_expire} );
+               if (!$memd->set( $context->digest(), $url_real, $cfg{cache_expire} )) {
+                       _log(LOG_INFO, "cannot save redirect from $url to $url_real in memcached");
+               }
        }
 }
 
@@ -318,7 +320,14 @@ sub process_client {
        elsif ( $http_response->code != 200 ) {
                _log( LOG_INFO, "HTTP response was %d, for request to %s",
                        $http_response->code, $http_request->uri );
-               my $new_response = create_response( $http_response->code );
+               my $new_response;
+               if ($rec == 0) {
+                       $new_response = create_response( $http_response->code );
+               }
+               else {
+                       memcached_cache_url( $base_url, $http_request->uri );
+                       $new_response = create_response( 200, $http_request->uri );
+               }
 
                # Avoid sending the response if the client has gone away.
                $heap->{client}->put($new_response) if defined $heap->{client};