From a335766bfe44a283625d0ad1192e08744cb3ac36 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Mon, 26 Nov 2018 10:36:59 +0100
Subject: [PATCH] - Keepalive enabled - ReUseAddress enabled - more detailed
 error log

---
 PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml |  2 +-
 .../plugin/SLUBVirusCheckClamAVPlugin.java         | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml b/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml
index e765e81..279f495 100644
--- a/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml
+++ b/PLUGIN-INF/metadata_SLUBVirusCheckClamAVPlugin.xml
@@ -49,7 +49,7 @@
 		</fr:x_form>
 	</pl:initParameters>
 	<pl:description>SLUB Virus Check Plugin using installed ClamAV daemon via tcp-sockets</pl:description>
-	<pl:version>1.5</pl:version>
+	<pl:version>1.6</pl:version>
 	<pl:materialType>DIGITAL</pl:materialType>
 	<pl:module>Repository</pl:module>
 	<pl:generalType>TASK</pl:generalType>
diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java
index a133abc..d8f569f 100644
--- a/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java
+++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java
@@ -186,6 +186,16 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
             //System.out.println("Could not set socket timeout to " + getTimeOut() + "ms " + e);
             log.error( "Could not set socket timeout to " + getTimeOut() + "ms", e);
         }
+        try {
+            socket.setKeepAlive(true);
+        } catch (SocketException e) {
+            log.error( "Could not enable KeepAlive", e);
+        }
+        try {
+            socket.setReuseAddress( true );
+        } catch (SocketException e) {
+            log.error( "Could not set ReUseAddress", e);
+        }
         return socket;
     }
 
@@ -286,7 +296,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
                 //System.out.println("clamd protocol not fully implemented");
             }
         } catch (IOException e) {
-            log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e);
+            log.error("exception creation socket in scan(), clamd not available at host=" + host + "port=" + port, e);
             //System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e);
             setStatus(Status.FAILED);
             setSignature("ERROR: clamd not available");
@@ -314,7 +324,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
             callSocketCommand(socket, command);
             return response.trim();
         } catch (IOException e) {
-            log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e);
+            log.error("exception creation socket in getAgent(), clamd not available at host=" + host + "port=" + port, e);
             //System.out.println("exception creation socket, clamd not available at host=" + host + "port=" + port + " " + e);
             setStatus(Status.FAILED);
             setSignature("ERROR: clamd not available");
-- 
GitLab