patch 7.4.1169
Problem: The socket I/O is intertwined with the netbeans code.
Solution: Start refactoring the netbeans communication to split off the
socket I/O. Add the +channel feature.
diff --git a/src/netbeans.c b/src/netbeans.c
index 2c15227..14f274d 100644
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -106,13 +106,7 @@
# define NB_HAS_GUI (gui.in_use || gui.starting)
#endif
-#ifdef WIN64
-typedef __int64 NBSOCK;
-#else
-typedef int NBSOCK;
-#endif
-
-static NBSOCK nbsock = -1; /* socket fd for Netbeans connection */
+static sock_T nbsock = -1; /* socket fd for Netbeans connection */
#define NETBEANS_OPEN (nbsock != -1)
#ifdef FEAT_GUI_X11
@@ -175,6 +169,7 @@
sock_close(nbsock);
nbsock = -1;
+ channel_remove_netbeans();
}
/*
@@ -243,8 +238,7 @@
if (*params == '=')
{
/* "=fname": Read info from specified file. */
- if (getConnInfo(params + 1, &hostname, &address, &password)
- == FAIL)
+ if (getConnInfo(params + 1, &hostname, &address, &password) == FAIL)
return FAIL;
}
else
@@ -312,13 +306,13 @@
goto theend; /* out of memory */
#ifdef FEAT_GUI_W32
- netbeans_init_winsock();
+ channel_init_winsock();
#endif
#ifdef INET_SOCKETS
port = atoi(address);
- if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
+ if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1)
{
nbdebug(("error in socket() in netbeans_connect()\n"));
PERROR("socket() in netbeans_connect()");
@@ -358,7 +352,7 @@
{
sock_close(sd);
#ifdef INET_SOCKETS
- if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
+ if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1)
{
SOCK_ERRNO;
nbdebug(("socket()#2 in netbeans_connect()\n"));
@@ -423,6 +417,7 @@
}
nbsock = sd;
+ channel_add_netbeans(nbsock);
vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
nb_send(buf, "netbeans_connect");
@@ -2954,7 +2949,7 @@
#endif
/*
- * Return TRUE when the netbeans connection is closed.
+ * Return TRUE when the netbeans connection is active.
*/
int
netbeans_active(void)
@@ -2962,15 +2957,6 @@
return NETBEANS_OPEN;
}
-/*
- * Return netbeans file descriptor.
- */
- int
-netbeans_filedesc(void)
-{
- return nbsock;
-}
-
#if defined(FEAT_GUI) || defined(PROTO)
/*
* Register our file descriptor with the gui event handling system.