[freenet-cvs] r16924 - trunk/freenet/src/freenet/io/comm

toad at freenetproject.org toad at freenetproject.org
Sat Jan 5 21:38:50 UTC 2008


Author: toad
Date: 2008-01-05 21:38:49 +0000 (Sat, 05 Jan 2008)
New Revision: 16924

Modified:
   trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
Log:
Fix a bug causing a shutdown timeout when exiting before we have started the UDP loop.

Modified: trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java	2008-01-05 21:26:37 UTC (rev 16923)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketHandler.java	2008-01-05 21:38:49 UTC (rev 16924)
@@ -40,6 +40,7 @@
 	private boolean _active = true;
 	private final int listenPort;
 	private final String title;
+	private boolean _started;
 	
 	public UdpSocketHandler(int listenPort, InetAddress bindto, Node node, long startupTime, String title) throws SocketException {
 		super("UDP packet receiver for "+title);
@@ -290,6 +291,10 @@
 		lastTimeInSeconds = (int) (System.currentTimeMillis() / 1000);
 		setDaemon(true);
 		setPriority(Thread.MAX_PRIORITY);
+		synchronized(this) {
+			if(!_active) return;
+			_started = true;
+		}
 		super.start();
 		if(!disableHangChecker) {
 			Thread checker = new Thread(new USMChecker(), "MessageCore$USMChecker");
@@ -364,6 +369,7 @@
     	Logger.normal(this, "Closing.", new Exception("error"));
 		synchronized (this) {
 			_active = false;
+			if(!_started) return;
 			while (!_isDone) {
 				try {
 					wait(2000);




More information about the cvs mailing list