46413: [2.1.3 Candidate] Reboot on W2K when synchronizing
diff --git a/bundles/org.eclipse.team.core/plugin.xml b/bundles/org.eclipse.team.core/plugin.xml
index b7f9fc7..18059dc 100644
--- a/bundles/org.eclipse.team.core/plugin.xml
+++ b/bundles/org.eclipse.team.core/plugin.xml
@@ -3,7 +3,7 @@
 <plugin
    id="org.eclipse.team.core"
    name="%pluginName"
-   version="2.1.1"
+   version="2.1.3"
    provider-name="%providerName"
    class="org.eclipse.team.internal.core.TeamPlugin">
 <requires>
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java
index 0c20579..0041e6b 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.team.internal.core.streams;
 
+import java.io.BufferedOutputStream;
 import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.InterruptedIOException;
@@ -56,7 +57,7 @@
 	 *        an InterruptedIOException; 0 blocks indefinitely, -1 closes the stream in the background
 	 */
 	public TimeoutOutputStream(OutputStream out, int bufferSize, long writeTimeout, long closeTimeout) {
-		super(out);
+		super(new BufferedOutputStream(out, bufferSize));
 		this.writeTimeout = writeTimeout;
 		this.closeTimeout = closeTimeout;
 		this.iobuffer = new byte[bufferSize];
@@ -249,6 +250,8 @@
 					bytesUntilFlush = length;
 				}
 			}
+			
+			// If there are bytes to be written, write them
 			if (len != 0) {
 				// write out all remaining bytes from the buffer before flushing
 				try {
@@ -258,12 +261,9 @@
 				} catch (InterruptedIOException e) {
 					len = e.bytesTransferred;
 				}
-				synchronized (this) {
-					head = (head + len) % iobuffer.length;
-					length -= len;
-					notify();
-				}
 			}
+			
+			// If there was a pending flush, do it
 			if (bytesUntilFlush >= 0) {
 				bytesUntilFlush -= len;
 				if (bytesUntilFlush <= 0) {
@@ -275,6 +275,15 @@
 					bytesUntilFlush = -1; // might have been 0
 				}
 			}
+			
+			// If bytes were written, update the circular buffer
+			if (len != 0) {
+				synchronized (this) {
+					head = (head + len) % iobuffer.length;
+					length -= len;
+					notify();
+				}
+			}
 		}
 	}
 }
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml
index 77ed182..741a1d3 100644
--- a/bundles/org.eclipse.team.cvs.core/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.core/plugin.xml
@@ -2,7 +2,7 @@
 <plugin
 	name="%pluginName"
 	id="org.eclipse.team.cvs.core"
-	version="2.1.1"
+	version="2.1.3"
     provider-name="%providerName"
 	class="org.eclipse.team.internal.ccvs.core.CVSProviderPlugin">
 
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
index e520f4a..e99e4f1 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
@@ -17,6 +17,7 @@
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
 import org.eclipse.team.internal.ccvs.core.IServerConnection;
 import org.eclipse.team.internal.ccvs.core.Policy;
@@ -71,7 +72,11 @@
 		try {
 			serverConnection.close();
 		} catch (IOException ex) {
-			throw new CVSCommunicationException(Policy.bind("Connection.cannotClose"), ex);//$NON-NLS-1$
+			// Generally, errors on close are of no interest.
+			// However, log them if debugging is on
+			if (CVSProviderPlugin.getPlugin().isDebugging()) {
+				CVSProviderPlugin.log(new CVSCommunicationException(Policy.bind("Connection.cannotClose"), ex));//$NON-NLS-1$
+			}
 		} finally {
 			fResponseStream = null;
 			fIsEstablished = false;