1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
To: vim_dev@googlegroups.com
Subject: Patch 7.3.060
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.060
Problem: Netbeans: crash when socket is disconnected unexpectedly.
Solution: Don't cleanup when a read fails, put a message in the queue and
disconnect later. (Xavier de Gaye)
Files: src/netbeans.c
*** ../vim-7.3.059/src/netbeans.c 2010-11-16 15:04:51.000000000 +0100
--- src/netbeans.c 2010-11-16 15:48:36.000000000 +0100
***************
*** 135,148 ****
static int needupdate = 0;
static int inAtomic = 0;
static void
! netbeans_close(void)
{
- if (!NETBEANS_OPEN)
- return;
-
- netbeans_send_disconnect();
-
#ifdef FEAT_GUI_X11
if (inputHandler != (XtInputId)NULL)
{
--- 135,146 ----
static int needupdate = 0;
static int inAtomic = 0;
+ /*
+ * Close the socket and remove the input handlers.
+ */
static void
! nb_close_socket(void)
{
#ifdef FEAT_GUI_X11
if (inputHandler != (XtInputId)NULL)
{
***************
*** 167,179 ****
# endif
#endif
#ifdef FEAT_BEVAL
bevalServers &= ~BEVAL_NETBEANS;
#endif
- sock_close(nbsock);
- nbsock = -1;
-
needupdate = 0;
inAtomic = 0;
nb_free();
--- 165,191 ----
# endif
#endif
+ sock_close(nbsock);
+ nbsock = -1;
+ }
+
+ /*
+ * Close the connection and cleanup.
+ * May be called when nb_close_socket() was called earlier.
+ */
+ static void
+ netbeans_close(void)
+ {
+ if (NETBEANS_OPEN)
+ {
+ netbeans_send_disconnect();
+ nb_close_socket();
+ }
+
#ifdef FEAT_BEVAL
bevalServers &= ~BEVAL_NETBEANS;
#endif
needupdate = 0;
inAtomic = 0;
nb_free();
***************
*** 632,640 ****
char_u *p;
queue_T *node;
- if (!NETBEANS_OPEN)
- return;
-
while (head.next != NULL && head.next != &head)
{
node = head.next;
--- 644,649 ----
***************
*** 720,725 ****
--- 729,736 ----
}
#endif
+ #define DETACH_MSG "DETACH\n"
+
void
netbeans_read()
{
***************
*** 780,801 ****
break; /* did read everything that's available */
}
if (readlen <= 0)
{
! /* read error or didn't read anything */
! netbeans_close();
! nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
if (len < 0)
{
nbdebug(("read from Netbeans socket\n"));
PERROR(_("read from Netbeans socket"));
}
- return; /* don't try to parse it */
}
#if defined(NB_HAS_GUI) && defined(FEAT_GUI_GTK)
if (NB_HAS_GUI && gtk_main_level() > 0)
! gtk_main_quit();
#endif
}
--- 791,822 ----
break; /* did read everything that's available */
}
+ /* Reading a socket disconnection (readlen == 0), or a socket error. */
if (readlen <= 0)
{
! /* Queue a "DETACH" netbeans message in the command queue in order to
! * terminate the netbeans session later. Do not end the session here
! * directly as we may be running in the context of a call to
! * netbeans_parse_messages():
! * netbeans_parse_messages
! * -> autocmd triggered while processing the netbeans cmd
! * -> ui_breakcheck
! * -> gui event loop or select loop
! * -> netbeans_read()
! */
! save((char_u *)DETACH_MSG, strlen(DETACH_MSG));
! nb_close_socket();
!
if (len < 0)
{
nbdebug(("read from Netbeans socket\n"));
PERROR(_("read from Netbeans socket"));
}
}
#if defined(NB_HAS_GUI) && defined(FEAT_GUI_GTK)
if (NB_HAS_GUI && gtk_main_level() > 0)
! gtk_main_quit();
#endif
}
***************
*** 1164,1169 ****
--- 1185,1194 ----
nbdebug(("REP %d: <none>\n", cmdno));
+ /* Avoid printing an annoying error message. */
+ if (!NETBEANS_OPEN)
+ return;
+
sprintf(reply, "%d\n", cmdno);
nb_send(reply, "nb_reply_nil");
}
***************
*** 2753,2763 ****
{
#ifdef FEAT_GUI
# if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \
! && !defined(FEAT_GUI_W32)
if (gui.in_use)
{
! EMSG(_("E838: netbeans is not supported with this GUI"));
! return;
}
# endif
#endif
--- 2778,2788 ----
{
#ifdef FEAT_GUI
# if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \
! && !defined(FEAT_GUI_W32)
if (gui.in_use)
{
! EMSG(_("E838: netbeans is not supported with this GUI"));
! return;
}
# endif
#endif
*** ../vim-7.3.059/src/version.c 2010-11-16 15:04:51.000000000 +0100
--- src/version.c 2010-11-16 15:22:39.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
{ /* Add new patch number below this line */
+ /**/
+ 60,
/**/
--
Another bucket of what can only be described as human ordure hits ARTHUR.
ARTHUR: ... Right! (to the KNIGHTS) That settles it!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|