From 95025349faabec99d6c6758351a5543caaa54c18 Mon Sep 17 00:00:00 2001
From: Spencer Oliver <spen@spen-soft.co.uk>
Date: Wed, 12 Dec 2012 15:42:01 +0000
Subject: [PATCH] helper: improve windows gdb pipe performance

Reducing the select and MsgWaitForMultipleObjects timeouts to 1ms makes
a 2-300+% increase in the step time of gdb when using pipes under windows OS.

Change-Id: Id7e52cfb2b206347a9caea61672885a3e2b186de
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1050
Tested-by: jenkins
---
 src/helper/replacements.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/helper/replacements.c b/src/helper/replacements.c
index 583e6162a..0ba98a488 100644
--- a/src/helper/replacements.c
+++ b/src/helper/replacements.c
@@ -206,10 +206,11 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
 			aexcept = sock_except;
 
 			tvslice.tv_sec = 0;
-			tvslice.tv_usec = 100000;
+			tvslice.tv_usec = 1000;
 
 			retcode = select(sock_max_fd + 1, &aread, &awrite, &aexcept, &tvslice);
 		}
+
 		if (n_handles > 0) {
 			/* check handles */
 			DWORD wret;
@@ -217,7 +218,7 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
 			wret = MsgWaitForMultipleObjects(n_handles,
 					handles,
 					FALSE,
-					retcode > 0 ? 0 : 100,
+					retcode > 0 ? 0 : 1,
 					QS_ALLEVENTS);
 
 			if (wret == WAIT_TIMEOUT) {