Skip to content

Commit 7f04847

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents b6ff854 + 8600ace commit 7f04847

11 files changed

+281
-216
lines changed

src/Make_cyg_ming.mak

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ DIRECTX=no
4242
FEATURES=HUGE
4343
# Set to one of i386, i486, i586, i686 as the minimum target processor.
4444
# For amd64/x64 architecture set ARCH=x86-64 .
45-
ARCH=i386
45+
ARCH=i686
4646
# Set to yes to cross-compile from unix; no=native Windows (and Cygwin).
4747
CROSS=no
4848
# Set to path to iconv.h and libiconv.a to enable using 'iconv.dll'.
@@ -58,9 +58,9 @@ DYNAMIC_IME=yes
5858
POSTSCRIPT=no
5959
# Set to yes to enable OLE support.
6060
OLE=no
61-
# Set the default $(WINVER) to make it work with pre-Win2k.
61+
# Set the default $(WINVER) to make it work with WinXP.
6262
ifndef WINVER
63-
WINVER = 0x0500
63+
WINVER = 0x0501
6464
endif
6565
# Set to yes to enable Cscope support.
6666
CSCOPE=yes
@@ -483,14 +483,14 @@ endif
483483
endif
484484

485485
ifdef PYTHON
486-
CFLAGS += -DFEAT_PYTHON
486+
CFLAGS += -DFEAT_PYTHON
487487
ifeq (yes, $(DYNAMIC_PYTHON))
488488
CFLAGS += -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"$(DYNAMIC_PYTHON_DLL)\"
489489
endif
490490
endif
491491

492-
ifdef PYTHON3
493-
CFLAGS += -DFEAT_PYTHON3
492+
ifdef PYTHON3
493+
CFLAGS += -DFEAT_PYTHON3
494494
ifeq (yes, $(DYNAMIC_PYTHON3))
495495
CFLAGS += -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"$(DYNAMIC_PYTHON3_DLL)\"
496496
endif

src/Make_mvc.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
# Processor Version: CPUNR=[i386, i486, i586, i686, pentium4] (default is
114114
# i386)
115115
#
116-
# Version Support: WINVER=[0x0400, 0x0500] (default is 0x0500)
116+
# Version Support: WINVER=[0x0501, 0x0600] (default is 0x0501)
117117
#
118118
# Debug version: DEBUG=yes
119119
# Mapfile: MAP=[no, yes or lines] (default is yes)
@@ -371,7 +371,7 @@ CON_LIB = $(CON_LIB) /DELAYLOAD:comdlg32.dll /DELAYLOAD:ole32.dll DelayImp.lib
371371

372372
### Set the default $(WINVER) to make it work with VC++7.0 (VS.NET)
373373
!ifndef WINVER
374-
WINVER = 0x0500
374+
WINVER = 0x0501
375375
!endif
376376

377377
# If you have a fixed directory for $VIM or $VIMRUNTIME, other than the normal

src/channel.c

Lines changed: 84 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,11 @@ channel_open(char *hostname, int port_in, int waittime, void (*close_cb)(void))
557557
}
558558
memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
559559

560-
#if defined(__APPLE__) && __APPLE__ == 1
561-
/* On Mac a zero timeout almost never works. At least wait one
562-
* millisecond. */
560+
/* On Mac and Solaris a zero timeout almost never works. At least wait
561+
* one millisecond. Let's do it for all systems, because we don't know why
562+
* this is needed. */
563563
if (waittime == 0)
564564
waittime = 1;
565-
#endif
566565

567566
/*
568567
* For Unix we need to call connect() again after connect() failed.
@@ -767,44 +766,25 @@ channel_set_job(channel_T *channel, job_T *job)
767766
channel->ch_job = job;
768767
}
769768

770-
/*
771-
* Set the mode of channel "channel" to "mode".
772-
*/
773-
void
774-
channel_set_mode(channel_T *channel, ch_mode_T mode)
775-
{
776-
channel->ch_mode = mode;
777-
}
778-
779-
/*
780-
* Set the read timeout of channel "channel".
781-
*/
782-
void
783-
channel_set_timeout(channel_T *channel, int timeout)
784-
{
785-
channel->ch_timeout = timeout;
786-
}
787-
788-
/*
789-
* Set the callback for channel "channel".
790-
*/
791-
void
792-
channel_set_callback(channel_T *channel, char_u *callback)
793-
{
794-
vim_free(channel->ch_callback);
795-
channel->ch_callback = vim_strsave(callback);
796-
}
797-
798769
/*
799770
* Set various properties from an "options" argument.
800771
*/
801772
void
802773
channel_set_options(channel_T *channel, jobopt_T *options)
803774
{
804-
channel_set_mode(channel, options->jo_mode);
775+
if (options->jo_set & JO_MODE)
776+
channel->ch_mode = options->jo_mode;
777+
if (options->jo_set & JO_TIMEOUT)
778+
channel->ch_timeout = options->jo_timeout;
805779

806-
if (options->jo_callback != NULL && *options->jo_callback != NUL)
807-
channel_set_callback(channel, options->jo_callback);
780+
if (options->jo_set & JO_CALLBACK)
781+
{
782+
vim_free(channel->ch_callback);
783+
if (options->jo_callback != NULL && *options->jo_callback != NUL)
784+
channel->ch_callback = vim_strsave(options->jo_callback);
785+
else
786+
channel->ch_callback = NULL;
787+
}
808788
}
809789

810790
/*
@@ -1527,17 +1507,11 @@ channel_free_all(void)
15271507
static int
15281508
channel_wait(channel_T *channel, sock_T fd, int timeout)
15291509
{
1530-
#if defined(HAVE_SELECT) && !defined(FEAT_GUI_W32)
1531-
struct timeval tval;
1532-
fd_set rfds;
1533-
int ret;
1534-
15351510
if (timeout > 0)
15361511
ch_logn(channel, "Waiting for up to %d msec", timeout);
15371512

1538-
15391513
# ifdef WIN32
1540-
if (channel->CH_SOCK == CHAN_FD_INVALID)
1514+
if (fd != channel->CH_SOCK)
15411515
{
15421516
DWORD nread;
15431517
int diff;
@@ -1556,44 +1530,48 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
15561530
* TODO: increase the sleep time when looping more often */
15571531
Sleep(5);
15581532
}
1559-
return FAIL;
15601533
}
1534+
else
15611535
#endif
1562-
1563-
FD_ZERO(&rfds);
1564-
FD_SET((int)fd, &rfds);
1565-
tval.tv_sec = timeout / 1000;
1566-
tval.tv_usec = (timeout % 1000) * 1000;
1567-
for (;;)
15681536
{
1569-
ret = select((int)fd + 1, &rfds, NULL, NULL, &tval);
1570-
# ifdef EINTR
1571-
if (ret == -1 && errno == EINTR)
1572-
continue;
1573-
# endif
1574-
if (ret <= 0)
1537+
#if defined(FEAT_GUI_W32)
1538+
/* Can't check socket for Win32 GUI, always return OK. */
1539+
ch_log(channel, "Can't check, assuming there is something to read");
1540+
return OK;
1541+
#else
1542+
# if defined(HAVE_SELECT)
1543+
struct timeval tval;
1544+
fd_set rfds;
1545+
int ret;
1546+
1547+
FD_ZERO(&rfds);
1548+
FD_SET((int)fd, &rfds);
1549+
tval.tv_sec = timeout / 1000;
1550+
tval.tv_usec = (timeout % 1000) * 1000;
1551+
for (;;)
15751552
{
1576-
ch_log(channel, "Nothing to read");
1577-
return FAIL;
1553+
ret = select((int)fd + 1, &rfds, NULL, NULL, &tval);
1554+
# ifdef EINTR
1555+
SOCK_ERRNO;
1556+
if (ret == -1 && errno == EINTR)
1557+
continue;
1558+
# endif
1559+
if (ret > 0)
1560+
return OK;
1561+
break;
15781562
}
1579-
break;
1580-
}
1581-
#else
1582-
# ifdef HAVE_POLL
1583-
struct pollfd fds;
1563+
# else
1564+
struct pollfd fds;
15841565

1585-
if (timeout > 0)
1586-
ch_logn(channel, "Waiting for %d msec", timeout);
1587-
fds.fd = fd;
1588-
fds.events = POLLIN;
1589-
if (poll(&fds, 1, timeout) <= 0)
1590-
{
1591-
ch_log(channel, "Nothing to read");
1592-
return FAIL;
1593-
}
1566+
fds.fd = fd;
1567+
fds.events = POLLIN;
1568+
if (poll(&fds, 1, timeout) > 0)
1569+
return OK;
15941570
# endif
15951571
#endif
1596-
return OK;
1572+
}
1573+
ch_log(channel, "Nothing to read");
1574+
return FAIL;
15971575
}
15981576

15991577
/*
@@ -1686,8 +1664,9 @@ channel_read(channel_T *channel, int which, char *func)
16861664
}
16871665
#endif
16881666

1689-
/* Reading a socket disconnection (readlen == 0), or a socket error. */
1690-
if (readlen <= 0)
1667+
/* Reading a socket disconnection (readlen == 0), or a socket error.
1668+
* TODO: call error callback. */
1669+
if (readlen <= 0 && channel->ch_job == NULL)
16911670
{
16921671
/* Queue a "DETACH" netbeans message in the command queue in order to
16931672
* terminate the netbeans session later. Do not end the session here
@@ -1855,6 +1834,35 @@ channel_fd2channel(sock_T fd, int *whichp)
18551834
}
18561835
return NULL;
18571836
}
1837+
1838+
void
1839+
channel_handle_events(void)
1840+
{
1841+
channel_T *channel;
1842+
int which;
1843+
static int loop = 0;
1844+
1845+
/* Skip heavily polling */
1846+
if (loop++ % 2)
1847+
return;
1848+
1849+
for (channel = first_channel; channel != NULL; channel = channel->ch_next)
1850+
{
1851+
# ifdef FEAT_GUI_W32
1852+
/* only check the pipes */
1853+
for (which = CHAN_OUT; which < CHAN_ERR; ++which)
1854+
# else
1855+
# ifdef CHANNEL_PIPES
1856+
/* check the socket and pipes */
1857+
for (which = CHAN_SOCK; which < CHAN_ERR; ++which)
1858+
# else
1859+
/* only check the socket */
1860+
which = CHAN_SOCK;
1861+
# endif
1862+
# endif
1863+
channel_read(channel, which, "channel_handle_events");
1864+
}
1865+
}
18581866
# endif
18591867

18601868
/*
@@ -1988,7 +1996,7 @@ channel_poll_check(int ret_in, void *fds_in)
19881996
}
19891997
# endif /* UNIX && !HAVE_SELECT */
19901998

1991-
# if (!defined(FEAT_GUI_W32) && defined(HAVE_SELECT)) || defined(PROTO)
1999+
# if (!defined(WIN32) && defined(HAVE_SELECT)) || defined(PROTO)
19922000
/*
19932001
* The type of "rfds" is hidden to avoid problems with the function proto.
19942002
*/
@@ -2053,7 +2061,7 @@ channel_select_check(int ret_in, void *rfds_in)
20532061

20542062
return ret;
20552063
}
2056-
# endif /* !FEAT_GUI_W32 && HAVE_SELECT */
2064+
# endif /* !WIN32 && HAVE_SELECT */
20572065

20582066
/*
20592067
* Execute queued up commands.

0 commit comments

Comments
 (0)