mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 7.4.1527
Problem: Channel test is flaky on MS-Windows. Solution: Limit the select() timeout to 50 msec and try with a new socket if it fails.
This commit is contained in:
@@ -628,9 +628,8 @@ channel_open(
|
|||||||
*/
|
*/
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
|
||||||
long elapsed_msec = 0;
|
long elapsed_msec = 0;
|
||||||
#endif
|
int waitnow;
|
||||||
|
|
||||||
if (sd >= 0)
|
if (sd >= 0)
|
||||||
sock_close(sd);
|
sock_close(sd);
|
||||||
@@ -688,7 +687,7 @@ channel_open(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If connect() didn't finish then try using select() to wait for the
|
/* If connect() didn't finish then try using select() to wait for the
|
||||||
* connection to be made. */
|
* connection to be made. For Win32 always use select() to wait. */
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (errno != ECONNREFUSED)
|
if (errno != ECONNREFUSED)
|
||||||
#endif
|
#endif
|
||||||
@@ -702,19 +701,22 @@ channel_open(
|
|||||||
struct timeval start_tv;
|
struct timeval start_tv;
|
||||||
struct timeval end_tv;
|
struct timeval end_tv;
|
||||||
#endif
|
#endif
|
||||||
|
/* Limit the waittime to 50 msec. If it doesn't work within this
|
||||||
|
* time we close the socket and try creating it again. */
|
||||||
|
waitnow = waittime > 50 ? 50 : waittime;
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(sd, &rfds);
|
FD_SET(sd, &rfds);
|
||||||
FD_ZERO(&wfds);
|
FD_ZERO(&wfds);
|
||||||
FD_SET(sd, &wfds);
|
FD_SET(sd, &wfds);
|
||||||
|
|
||||||
tv.tv_sec = waittime / 1000;
|
tv.tv_sec = waitnow / 1000;
|
||||||
tv.tv_usec = (waittime % 1000) * 1000;
|
tv.tv_usec = (waitnow % 1000) * 1000;
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
gettimeofday(&start_tv, NULL);
|
gettimeofday(&start_tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
ch_logn(channel,
|
ch_logn(channel,
|
||||||
"Waiting for connection (waittime %d msec)...", waittime);
|
"Waiting for connection (waiting %d msec)...", waitnow);
|
||||||
ret = select((int)sd + 1, &rfds, &wfds, NULL, &tv);
|
ret = select((int)sd + 1, &rfds, &wfds, NULL, &tv);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -729,10 +731,16 @@ channel_open(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/* On Win32: select() is expected to work and wait for up to the
|
/* On Win32: select() is expected to work and wait for up to
|
||||||
* waittime for the socket to be open. */
|
* "waitnow" msec for the socket to be open. */
|
||||||
if (FD_ISSET(sd, &wfds))
|
if (FD_ISSET(sd, &wfds))
|
||||||
break;
|
break;
|
||||||
|
elapsed_msec = waitnow;
|
||||||
|
if (waittime > 1 && elapsed_msec < waittime)
|
||||||
|
{
|
||||||
|
waittime -= elapsed_msec;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* On Linux-like systems: See socket(7) for the behavior
|
/* On Linux-like systems: See socket(7) for the behavior
|
||||||
* After putting the socket in non-blocking mode, connect() will
|
* After putting the socket in non-blocking mode, connect() will
|
||||||
@@ -778,17 +786,20 @@ channel_open(
|
|||||||
{
|
{
|
||||||
/* The port isn't ready but we also didn't get an error.
|
/* The port isn't ready but we also didn't get an error.
|
||||||
* This happens when the server didn't open the socket
|
* This happens when the server didn't open the socket
|
||||||
* yet. Wait a bit and try again. */
|
* yet. Select() may return early, wait until the remaining
|
||||||
mch_delay(waittime < 50 ? (long)waittime : 50L, TRUE);
|
* "waitnow" and try again. */
|
||||||
|
waitnow -= elapsed_msec;
|
||||||
|
waittime -= elapsed_msec;
|
||||||
|
if (waitnow > 0)
|
||||||
|
{
|
||||||
|
mch_delay((long)waitnow, TRUE);
|
||||||
ui_breakcheck();
|
ui_breakcheck();
|
||||||
|
waittime -= waitnow;
|
||||||
|
}
|
||||||
if (!got_int)
|
if (!got_int)
|
||||||
{
|
{
|
||||||
/* reduce the waittime by the elapsed time and the 50
|
if (waittime <= 0)
|
||||||
* msec delay (or a bit more) */
|
/* give it one more try */
|
||||||
waittime -= elapsed_msec;
|
|
||||||
if (waittime > 50)
|
|
||||||
waittime -= 50;
|
|
||||||
else
|
|
||||||
waittime = 1;
|
waittime = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -743,6 +743,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1527,
|
||||||
/**/
|
/**/
|
||||||
1526,
|
1526,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user