Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Fix logging in serverCore Prevent NPEs from keeping stopped Sessions in the pool and blocking slots

hermens02dfd6183bef
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index dc4fe7b01..9a44ed5e5 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -532,7 +532,7 @@ public final class serverCore extends serverAbstractBusyThread implements server
if (this.controlSocket != null) try {
this.controlSocket.close();
serverCore.this.log.logInfo("Closing main socket of thread '" + this.getName() + "'");
- this.controlSocket = null;
+ //this.controlSocket = null;
} catch (final Exception e) {}
}
@@ -620,24 +620,23 @@ public final class serverCore extends serverAbstractBusyThread implements server
System.err.println("ERROR: (internal) " + e);
} finally {
try {
- if ((this.controlSocket == null) || this.controlSocket.isClosed()) return;
-
- // flush data
- this.out.flush();
+ if ((this.controlSocket != null) && (! this.controlSocket.isClosed())) {
+ // flush data
+ this.out.flush();
- // maybe this doesn't work for all SSL socket implementations
- if (!(this.controlSocket instanceof SSLSocket)) {
- this.controlSocket.shutdownInput();
- this.controlSocket.shutdownOutput();
- }
+ // maybe this doesn't work for all SSL socket implementations
+ if (!(this.controlSocket instanceof SSLSocket)) {
+ this.controlSocket.shutdownInput();
+ this.controlSocket.shutdownOutput();
+ }
- // close streams
- this.in.close();
- this.out.close();
+ // close streams
+ this.in.close();
+ this.out.close();
- // close everything
- this.controlSocket.close();
-
+ // close everything
+ this.controlSocket.close();
+ }
} catch (final IOException e) {
e.printStackTrace();
}
diff --git a/source/yacy.java b/source/yacy.java
index d143ded05..9879061ed 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -338,6 +338,8 @@ public final class yacy {
// first start the server
sb.deployThread("10_httpd", "HTTPD Server/Proxy", "the HTTPD, used as web server and proxy", null, server, 0, 0, 0, 0);
//server.start();
+ // repair log settings, gets overwritten with "PLASMA" in deployThread
+ server.setLog(new Log("SERVER"));
// open the browser window
final boolean browserPopUpTrigger = sb.getConfig(plasmaSwitchboardConstants.BROWSER_POP_UP_TRIGGER, "true").equals("true");