[377845] The server timeout timer begins at the incorrect time (port to 3.3.2 patches)
diff --git a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
index 2766708..7d8a423 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
+++ b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
@@ -4,21 +4,17 @@
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Build" content="Build">
-   <title>WTP 3.2.5 Patches</title>
+   <title>WTP 3.3.2 Patches</title>
 </head>
 
 <body>
 
-<h1>WTP 3.2.5 Patches</h1>
+<h1>WTP 3.3.2 Patches</h1>
 
 <h2>Feature Patched: org.eclipse.wst.server_core.feature</h2>
 <h3>Plugin(s) replaced:</h3>
 <ul><li>org.eclipse.wst.server.core</li></ul>
-<p>Bug <a href='https://bugs.eclipse.org/364482'>364482</a>. A race condition could occur in Server code</p>
-<p>Bug <a href='https://bugs.eclipse.org/370832'>370832</a>. Auto publish will not triggered for structure changes</p>
-<p>Bug <a href='https://bugs.eclipse.org/370992'>370992</a>. Extensible Server Start Jobs</p>
-<p>Bug <a href='https://bugs.eclipse.org/377566'>377566</a>. The server timeout timer begins at the incorrect time</p>
-<p>Bug <a href='https://bugs.eclipse.org/377835'>377835</a>. The JavaDoc and implementation isn't consistent for utility method ServerUtil.setRuntimeDefaultName() - Port to WTP 3.2.5 patches</p>
+<p>Bug <a href='https://bugs.eclipse.org/377845'>377845</a>. The server timeout timer begins at the incorrect time (port to 3.3.2 patches)</p>
 
 
 </body></html>
\ No newline at end of file
diff --git a/features/org.eclipse.wst.server_core.feature.patch/epl-v10.html b/features/org.eclipse.wst.server_core.feature.patch/epl-v10.html
index abeecc4..fd39122 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/epl-v10.html
+++ b/features/org.eclipse.wst.server_core.feature.patch/epl-v10.html
@@ -41,7 +41,6 @@
 <p class="list">a) in the case of the initial Contributor, the initial
 code and documentation distributed under this Agreement, and</p>
 <p class="list">b) in the case of each subsequent Contributor:</p>
-
 <p class="list">i) changes to the Program, and</p>
 <p class="list">ii) additions to the Program;</p>
 <p class="list">where such changes and/or additions to the Program
diff --git a/features/org.eclipse.wst.server_core.feature.patch/feature.properties b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
index 3282694..e9c9606 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/feature.properties
+++ b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
@@ -27,11 +27,7 @@
 description=\
 Contains fixes described in the following bugzilla(s):\n\
 \n\
-Bug https://bugs.eclipse.org/364482 A race condition could occur in Server code\n\
-Bug https://bugs.eclipse.org/370832 Auto publish will not triggered for structure changes\n\
-Bug https://bugs.eclipse.org/370992 Extensible Server Start Jobs\n\
-Bug https://bugs.eclipse.org/377566 The server timeout timer begins at the incorrect time\n\
-Bug https://bugs.eclipse.org/377835 The JavaDoc and implementation isn't consistent for utility method ServerUtil.setRuntimeDefaultName() - Port to WTP 3.2.5 patches\n\
+Bug https://bugs.eclipse.org/377845 The server timeout timer begins at the incorrect time (port to 3.3.2 patches)\n\
 \n\
 # "copyright" property - text of the "Feature Update Copyright"
 copyright=\
@@ -53,7 +49,7 @@
 # should be plain text version of license agreement pointed to be "licenseURL"
 license=\
 Eclipse Foundation Software User Agreement\n\
-April 14, 2010\n\
+February 1, 2011\n\
 \n\
 Usage Of Content\n\
 \n\
@@ -122,6 +118,7 @@
 TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
 SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
 \n\
+       - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
        - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
        - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
        - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
diff --git a/features/org.eclipse.wst.server_core.feature.patch/feature.xml b/features/org.eclipse.wst.server_core.feature.patch/feature.xml
index e148ee8..6eb67c1 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/feature.xml
+++ b/features/org.eclipse.wst.server_core.feature.patch/feature.xml
@@ -1,18 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <feature
       id="org.eclipse.wst.server_core.feature.patch"
-    label="%featureName"
-    version="3.2.5.qualifier"
-    provider-name="%providerName">
+      label="%featureName"
+      version="3.3.2.qualifier"
+      provider-name="%providerName">
 
-    <description>%description</description>
+   <description>
+      %description
+   </description>
 
-    <copyright>%copyright</copyright>
+   <copyright>
+      %copyright
+   </copyright>
 
-    <license url="%licenseURL">%license</license>
+   <license url="%licenseURL">
+      %license
+   </license>
 
    <requires>
-      <import feature="org.eclipse.wst.server_core.feature" version="3.2.5.v20110729_1202-30F8_8s7355463Ha2845" patch="true"/>
+      <import feature="org.eclipse.wst.server_core.feature" version="3.3.2.v20111026_1748-30FBd8s7356394Ka2531" patch="true"/>
    </requires>
 
    <plugin
diff --git a/features/org.eclipse.wst.server_core.feature.patch/license.html b/features/org.eclipse.wst.server_core.feature.patch/license.html
index c184ca3..f19c483 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/license.html
+++ b/features/org.eclipse.wst.server_core.feature.patch/license.html
@@ -8,7 +8,7 @@
 
 <body lang="EN-US">
 <h2>Eclipse Foundation Software User Agreement</h2>
-<p>April 14, 2010</p>
+<p>February 1, 2011</p>
 
 <h3>Usage Of Content</h3>
 
@@ -58,6 +58,7 @@
 OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
 
 <ul>
+       <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li>
        <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
        <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
        <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
diff --git a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
index 3508df3..826b8ba 100644
--- a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.server.core; singleton:=true
-Bundle-Version: 1.1.304.qualifier
+Bundle-Version: 1.1.305.qualifier
 Bundle-Activator: org.eclipse.wst.server.core.internal.ServerPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
index d5046bb..23c2494 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
@@ -3246,8 +3246,6 @@
 				}
 			}
 		};
-		thread.setDaemon(true);
-		thread.start();
 		
 		if (Trace.FINEST) {
 			Trace.trace(Trace.STRING_FINEST, "synchronousRestart 2");
@@ -3256,6 +3254,9 @@
 		// call the delegate restart
 		try {
 			getBehaviourDelegate(null).restart(launchMode);
+			
+			thread.setDaemon(true);
+			thread.start();			
 		} catch (CoreException e) {
 			removeServerListener(listener);
 			timer.alreadyDone = true;
@@ -3388,8 +3389,6 @@
 				}
 			}
 		};
-		thread.setDaemon(true);
-		thread.start();
 	
 		if (Trace.FINEST) {
 			Trace.trace(Trace.STRING_FINEST, "synchronousStart 2");
@@ -3398,6 +3397,9 @@
 		// start the server
 		try {
 			startImpl2(launchMode, monitor);
+			
+			thread.setDaemon(true);
+			thread.start();			
 		} catch (CoreException e) {
 			removeServerListener(listener);
 			timer.alreadyDone = true;
@@ -3511,11 +3513,23 @@
 		final Timer timer = new Timer();
 		
 		final int serverTimeout = getStopTimeout() * 1000;
+		Thread thread = null;
 		if (serverTimeout > 0) {
-			Thread thread = new Thread("Server Stop Timeout") {
+			thread = new Thread("Server Stop Timeout") {
 				public void run() {
-					try {
-						Thread.sleep(serverTimeout);
+					try {					
+						int totalTimeout = serverTimeout;
+						if (totalTimeout < 0)
+							totalTimeout = 1;
+						
+						int retryPeriod = 1000;						
+
+						while (totalTimeout > 0 && !timer.alreadyDone){
+							Thread.sleep(retryPeriod);
+							if (serverTimeout > 0)
+								totalTimeout -= retryPeriod;
+						}
+
 						if (!timer.alreadyDone) {
 							timer.timeout = true;
 							// notify waiter
@@ -3533,13 +3547,16 @@
 					}
 				}
 			};
-			thread.setDaemon(true);
-			thread.start();
 		}
 		
 		// stop the server
 		stopImpl2(force);
 		
+		if (thread != null){
+			thread.setDaemon(true);
+			thread.start();
+		}
+		
 		// wait for it! wait for it!
 		synchronized (mutex) {
 			try {
@@ -3551,6 +3568,7 @@
 					Trace.trace(Trace.STRING_SEVERE, "Error waiting for server stop", e);
 				}
 			}
+			timer.alreadyDone = true;
 		}
 		removeServerListener(listener);