From: Vsevolod Stakhov Date: Wed, 3 Aug 2016 17:10:57 +0000 (+0100) Subject: [Fix] Fix buffering in CGP integration X-Git-Tag: 1.3.2~57 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9fd26f1ff73dd5c3eee81dc17f1cf69445b9ae4c;p=rspamd.git [Fix] Fix buffering in CGP integration --- diff --git a/utils/cgp_rspamd.pl b/utils/cgp_rspamd.pl index 41a48026b..f9e0bb4d7 100644 --- a/utils/cgp_rspamd.pl +++ b/utils/cgp_rspamd.pl @@ -29,6 +29,10 @@ GetOptions( pod2usage(1) if $help; pod2usage(-exitval => 0, -verbose => 2) if $man; +my $scanned = 0; +# Turn off bufferization as required by CGP +$| = 1; + sub cgp_string { my ($in) = @_; @@ -47,6 +51,7 @@ sub rspamd_scan { if ($hdr->{Status} =~ /^2/) { my $js = decode_json($body); + $scanned ++; if (!$js) { print "* Rspamd: Bad response for $file: invalid JSON: parse error\n"; @@ -126,6 +131,11 @@ my $w = AnyEvent->io( print "* Scanning file $file\n"; rspamd_scan $tag, $file; } + elsif ($cmd eq "QUIT") { + print "* Terminating after scanning of $scanned files\n"; + print "$tag OK\n"; + exit 0; + } } } );