summaryrefslogtreecommitdiffstats
path: root/utils/redirector.pl.in
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-16 19:09:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-16 19:09:36 +0100
commit5ad7492c725e5b3e383f343fbc410fcea28f7e0e (patch)
treee9a554d1fc54e221526192a6590acb066c1b466f /utils/redirector.pl.in
parent72cd49153aee41edaf5259a2055c990abc8db0aa (diff)
downloadrspamd-5ad7492c725e5b3e383f343fbc410fcea28f7e0e.tar.gz
rspamd-5ad7492c725e5b3e383f343fbc410fcea28f7e0e.zip
Store partial results in memcached.
Diffstat (limited to 'utils/redirector.pl.in')
-rwxr-xr-xutils/redirector.pl.in13
1 files changed, 11 insertions, 2 deletions
diff --git a/utils/redirector.pl.in b/utils/redirector.pl.in
index 704f5749b..b483c127f 100755
--- a/utils/redirector.pl.in
+++ b/utils/redirector.pl.in
@@ -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};