From dd4f4b34c3b7e005ede215ca56a4b4d931ca4ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Weigert?= Date: Fri, 21 May 2021 20:01:48 +0200 Subject: [PATCH 1/2] Hotfix for files for slow virus scanner responses This implements the hotfix suggsted in #443 --- lib/Scanner/ICAPClient.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Scanner/ICAPClient.php b/lib/Scanner/ICAPClient.php index b848857a..2c104e34 100644 --- a/lib/Scanner/ICAPClient.php +++ b/lib/Scanner/ICAPClient.php @@ -126,9 +126,9 @@ private function send(string $request): string { } # McAfee seems to not properly close the socket once all response bytes are sent to the client - # we use a 10 sec time out on receiving data - \stream_set_timeout($this->writeHandle, 10, 0); - $response = ''; + # Use a timeout after(!) the first read. + $response = \fread($this->writeHandle, 2048); + \stream_set_timeout($this->writeHandle, 2, 0); while ($buffer = \fread($this->writeHandle, 2048)) { $response .= $buffer; } From f00fc73913915702d180cbb950b6262eaf30e074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Weigert?= Date: Fri, 21 May 2021 20:34:25 +0200 Subject: [PATCH 2/2] Update ICAPClient.php Php seems to have a low default timeout. Let's start with 300 sec. that allows me to process ca 100 MB --- lib/Scanner/ICAPClient.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Scanner/ICAPClient.php b/lib/Scanner/ICAPClient.php index 2c104e34..6ab0f44a 100644 --- a/lib/Scanner/ICAPClient.php +++ b/lib/Scanner/ICAPClient.php @@ -126,7 +126,8 @@ private function send(string $request): string { } # McAfee seems to not properly close the socket once all response bytes are sent to the client - # Use a timeout after(!) the first read. + # Use a short timeout only after(!) the first read. + \stream_set_timeout($this->writeHandle, 300, 0); $response = \fread($this->writeHandle, 2048); \stream_set_timeout($this->writeHandle, 2, 0); while ($buffer = \fread($this->writeHandle, 2048)) {