Index: generic/tclTimer.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTimer.c,v
retrieving revision 1.40
diff -u -r1.40 tclTimer.c
--- generic/tclTimer.c	7 Sep 2009 07:28:38 -0000	1.40
+++ generic/tclTimer.c	30 Nov 2009 00:17:21 -0000
@@ -1003,7 +1003,8 @@
     Tcl_Time endTime, now;
     Tcl_WideInt diff;
 
-    Tcl_GetTime(&endTime);
+    Tcl_GetTime(&now);
+    endTime = now;
     endTime.sec += (long)(ms/1000);
     endTime.usec += ((int)(ms%1000))*1000;
     if (endTime.usec >= 1000000) {
@@ -1012,7 +1013,6 @@
     }
 
     do {
-	Tcl_GetTime(&now);
 	if (Tcl_AsyncReady()) {
 	    if (Tcl_AsyncInvoke(interp, TCL_OK) != TCL_OK) {
 		return TCL_ERROR;
@@ -1030,17 +1030,23 @@
 	}
 	if (iPtr->limit.timeEvent == NULL
 	    || TCL_TIME_BEFORE(endTime, iPtr->limit.time)) {
+            int complete = 1;
 	    diff = TCL_TIME_DIFF_MS(endTime, now);
 #ifndef TCL_WIDE_INT_IS_LONG
 	    if (diff > LONG_MAX) {
 		diff = LONG_MAX;
+                complete = 0;
 	    }
 #endif
 	    if (diff > TCL_TIME_MAXIMUM_SLICE) {
 		diff = TCL_TIME_MAXIMUM_SLICE;
+                complete=0;
 	    }
 	    if (diff > 0) {
 		Tcl_Sleep((long)diff);
+                if (complete) break;
+	    } else {
+		break;
 	    }
 	} else {
 	    diff = TCL_TIME_DIFF_MS(iPtr->limit.time, now);
@@ -1054,6 +1060,8 @@
 	    }
 	    if (diff > 0) {
 		Tcl_Sleep((long)diff);
+	    } else {
+		break;
 	    }
 	    if (Tcl_AsyncReady()) {
 		if (Tcl_AsyncInvoke(interp, TCL_OK) != TCL_OK) {
@@ -1067,6 +1075,7 @@
 		return TCL_ERROR;
 	    }
 	}
+	Tcl_GetTime(&now);
     } while (TCL_TIME_BEFORE(now, endTime));
     return TCL_OK;
 }
@@ -1270,5 +1279,7 @@
  * mode: c
  * c-basic-offset: 4
  * fill-column: 78
+ * tab-width: 8
+ * indent-tabs-mode: nil
  * End:
  */
