aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2010-02-10 10:31:24 +0100
committerJan Djärv2010-02-10 10:31:24 +0100
commit50b51e49a1e3a2f324efeca1e5099532e3ea335b (patch)
treefd1252c6cd76e91c4fc348bf8ea4d91bc96883c3 /src
parente6d23bb58018ffe2cdaf5faa01c245c1a49bd0f8 (diff)
parent182659ae3cf6d4c2633f3f3dbac8fd3bc5b3f627 (diff)
downloademacs-50b51e49a1e3a2f324efeca1e5099532e3ea335b.tar.gz
emacs-50b51e49a1e3a2f324efeca1e5099532e3ea335b.zip
Fix for bug#5512, don't rely on SIGIO alone.
* xsmfns.c (x_session_initialize): Move initialization of ice_fd and doing_interact here. (ice_connection_closed): New function. (x_session_check_input, smc_die_CB, ice_io_error_handler) (ice_conn_watch_CB, x_session_close): Call ice_connection_closed. (x_session_check_input): Call IceCloseConnection if IceProcessMessages returns I/O error. (ice_conn_watch_CB): Call add_keyboard_wait_descriptor on ice_fd, bug #5512.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/xsmfns.c62
2 files changed, 53 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d022ada1fc4..c2775efdef0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12010-02-10 Jan Djärv <jan.h.d@swipnet.se>
2
3 * xsmfns.c (x_session_initialize): Move initialization of ice_fd and
4 doing_interact here.
5 (ice_connection_closed): New function.
6 (x_session_check_input, smc_die_CB, ice_io_error_handler)
7 (ice_conn_watch_CB, x_session_close): Call ice_connection_closed.
8 (x_session_check_input): Call IceCloseConnection if IceProcessMessages
9 returns I/O error.
10 (ice_conn_watch_CB): Call add_keyboard_wait_descriptor on ice_fd,
11 bug #5512.
12
12010-02-08 Francis Devereux <francis@devrx.org> (tiny change) 132010-02-08 Francis Devereux <francis@devrx.org> (tiny change)
2 14
3 * nsfont.m (nsfont_open): The system's value for the font descent 15 * nsfont.m (nsfont_open): The system's value for the font descent
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 55035816bfd..ec5ca3b1a9f 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -52,11 +52,11 @@ static struct input_event emacs_event;
52 52
53/* The descriptor that we use to check for data from the session manager. */ 53/* The descriptor that we use to check for data from the session manager. */
54 54
55static int ice_fd = -1; 55static int ice_fd;
56 56
57/* A flag that says if we are in shutdown interactions or not. */ 57/* A flag that says if we are in shutdown interactions or not. */
58 58
59static int doing_interact = False; 59static int doing_interact;
60 60
61/* The session manager object for the session manager connection. */ 61/* The session manager object for the session manager connection. */
62 62
@@ -90,6 +90,14 @@ Lisp_Object Vx_session_previous_id;
90 90
91#define NOSPLASH_OPT "--no-splash" 91#define NOSPLASH_OPT "--no-splash"
92 92
93static void
94ice_connection_closed ()
95{
96 if (ice_fd >= 0)
97 delete_keyboard_wait_descriptor (ice_fd);
98 ice_fd = -1;
99}
100
93 101
94/* Handle any messages from the session manager. If no connection is 102/* Handle any messages from the session manager. If no connection is
95 open to a session manager, just return 0. 103 open to a session manager, just return 0.
@@ -101,9 +109,9 @@ x_session_check_input (bufp)
101{ 109{
102 SELECT_TYPE read_fds; 110 SELECT_TYPE read_fds;
103 EMACS_TIME tmout; 111 EMACS_TIME tmout;
112 int ret;
104 113
105 if (ice_fd == -1) return 0; 114 if (ice_fd == -1) return 0;
106
107 FD_ZERO (&read_fds); 115 FD_ZERO (&read_fds);
108 FD_SET (ice_fd, &read_fds); 116 FD_SET (ice_fd, &read_fds);
109 117
@@ -116,26 +124,33 @@ x_session_check_input (bufp)
116 will be called. */ 124 will be called. */
117 emacs_event.kind = NO_EVENT; 125 emacs_event.kind = NO_EVENT;
118 126
119 if (select (ice_fd+1, &read_fds, 127 ret = select (ice_fd+1, &read_fds,
120 (SELECT_TYPE *)0, (SELECT_TYPE *)0, &tmout) < 0) 128 (SELECT_TYPE *)0, (SELECT_TYPE *)0, &tmout);
129
130 if (ret < 0)
121 { 131 {
122 ice_fd = -1; 132 ice_connection_closed ();
123 return 0; 133 }
134 else if (ret > 0 && FD_ISSET (ice_fd, &read_fds))
135 {
136 ret = IceProcessMessages (SmcGetIceConnection (smc_conn),
137 (IceReplyWaitInfo *)0, (Bool *)0);
138 if (ret != IceProcessMessagesSuccess)
139 {
140 /* Either IO error or Connection closed. */
141 if (ret == IceProcessMessagesIOError)
142 IceCloseConnection (SmcGetIceConnection (smc_conn));
143
144 ice_connection_closed ();
145 }
124 } 146 }
125
126
127 if (FD_ISSET (ice_fd, &read_fds))
128 IceProcessMessages (SmcGetIceConnection (smc_conn),
129 (IceReplyWaitInfo *)0, (Bool *)0);
130
131 147
132 /* Check if smc_interact_CB was called and we shall generate a 148 /* Check if smc_interact_CB was called and we shall generate a
133 SAVE_SESSION_EVENT. */ 149 SAVE_SESSION_EVENT. */
134 if (emacs_event.kind == NO_EVENT) 150 if (emacs_event.kind != NO_EVENT)
135 return 0; 151 bcopy (&emacs_event, bufp, sizeof (struct input_event));
136 152
137 bcopy (&emacs_event, bufp, sizeof (struct input_event)); 153 return emacs_event.kind != NO_EVENT ? 1 : 0;
138 return 1;
139} 154}
140 155
141/* Return non-zero if we have a connection to a session manager. */ 156/* Return non-zero if we have a connection to a session manager. */
@@ -284,7 +299,7 @@ smc_die_CB (smcConn, clientData)
284 SmPointer clientData; 299 SmPointer clientData;
285{ 300{
286 SmcCloseConnection (smcConn, 0, 0); 301 SmcCloseConnection (smcConn, 0, 0);
287 ice_fd = -1; 302 ice_connection_closed ();
288} 303}
289 304
290/* We don't use the next two but they are mandatory, leave them empty. 305/* We don't use the next two but they are mandatory, leave them empty.
@@ -356,7 +371,7 @@ ice_io_error_handler (iceConn)
356 IceConn iceConn; 371 IceConn iceConn;
357{ 372{
358 /* Connection probably gone. */ 373 /* Connection probably gone. */
359 ice_fd = -1; 374 ice_connection_closed ();
360} 375}
361 376
362/* This is called when the ICE connection is created or closed. The SM library 377/* This is called when the ICE connection is created or closed. The SM library
@@ -371,7 +386,7 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData)
371{ 386{
372 if (! opening) 387 if (! opening)
373 { 388 {
374 ice_fd = -1; 389 ice_connection_closed ();
375 return; 390 return;
376 } 391 }
377 392
@@ -384,6 +399,8 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData)
384 if (interrupt_input) 399 if (interrupt_input)
385 init_sigio (ice_fd); 400 init_sigio (ice_fd);
386#endif /* ! defined (SIGIO) */ 401#endif /* ! defined (SIGIO) */
402
403 add_keyboard_wait_descriptor (ice_fd);
387} 404}
388 405
389/* Create the client leader window. */ 406/* Create the client leader window. */
@@ -426,6 +443,9 @@ x_session_initialize (dpyinfo)
426 SmcCallbacks callbacks; 443 SmcCallbacks callbacks;
427 int name_len = 0; 444 int name_len = 0;
428 445
446 ice_fd = -1;
447 doing_interact = False;
448
429 /* Check if we where started by the session manager. If so, we will 449 /* Check if we where started by the session manager. If so, we will
430 have a previous id. */ 450 have a previous id. */
431 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) 451 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id))
@@ -497,7 +517,7 @@ x_session_initialize (dpyinfo)
497void 517void
498x_session_close () 518x_session_close ()
499{ 519{
500 ice_fd = -1; 520 ice_connection_closed ();
501} 521}
502 522
503 523