Commit a631d0e0 authored by Paul Eggert's avatar Paul Eggert
Browse files

Fix problems in ns port found by static checking.

* nsterm.m: Include <pthread.h>, for pthread_mutex_lock etc.
(hold_event, setPosition:portion:whole:): Send SIGIO only to self,
not to process group.
(ns_select): Use emacs_write, not write, as that's more robust
in the presence of signals.
(fd_handler:): Check for read errors.
parent d76afb93
2012-11-17 Paul Eggert <eggert@cs.ucla.edu>
Fix problems in ns port found by static checking.
* nsterm.m: Include <pthread.h>, for pthread_mutex_lock etc.
(hold_event, setPosition:portion:whole:): Send SIGIO only to self,
not to process group.
(ns_select): Use emacs_write, not write, as that's more robust
in the presence of signals.
(fd_handler:): Check for read errors.
2012-11-16 Glenn Morris <rgm@gnu.org> 2012-11-16 Glenn Morris <rgm@gnu.org>
   
* editfns.c (Fmessage): Mention message-log-max. (Bug#12849) * editfns.c (Fmessage): Mention message-log-max. (Bug#12849)
......
...@@ -31,6 +31,7 @@ Updated by Christian Limpach (chris@nice.ch) ...@@ -31,6 +31,7 @@ Updated by Christian Limpach (chris@nice.ch)
#include <config.h> #include <config.h>
#include <math.h> #include <math.h>
#include <pthread.h>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <signal.h> #include <signal.h>
...@@ -331,7 +332,7 @@ Updated by Christian Limpach (chris@nice.ch) ...@@ -331,7 +332,7 @@ Updated by Christian Limpach (chris@nice.ch)
hold_event_q.q[hold_event_q.nr++] = *event; hold_event_q.q[hold_event_q.nr++] = *event;
/* Make sure ns_read_socket is called, i.e. we have input. */ /* Make sure ns_read_socket is called, i.e. we have input. */
kill (0, SIGIO); raise (SIGIO);
} }
static Lisp_Object static Lisp_Object
...@@ -3389,7 +3390,7 @@ overwriting cursor (usually when cursor on a tab) */ ...@@ -3389,7 +3390,7 @@ overwriting cursor (usually when cursor on a tab) */
if ([NSApp modalWindow] != nil) if ([NSApp modalWindow] != nil)
return -1; return -1;
if (hold_event_q.nr > 0) if (hold_event_q.nr > 0)
{ {
int i; int i;
for (i = 0; i < hold_event_q.nr; ++i) for (i = 0; i < hold_event_q.nr; ++i)
...@@ -3504,7 +3505,7 @@ overwriting cursor (usually when cursor on a tab) */ ...@@ -3504,7 +3505,7 @@ overwriting cursor (usually when cursor on a tab) */
/* Inform fd_handler that select should be called */ /* Inform fd_handler that select should be called */
c = 'g'; c = 'g';
write (selfds[1], &c, 1); emacs_write (selfds[1], &c, 1);
} }
else if (nr == 0 && timeout) else if (nr == 0 && timeout)
{ {
...@@ -3537,7 +3538,7 @@ overwriting cursor (usually when cursor on a tab) */ ...@@ -3537,7 +3538,7 @@ overwriting cursor (usually when cursor on a tab) */
if (nr > 0 && readfds) if (nr > 0 && readfds)
{ {
c = 's'; c = 's';
write (selfds[1], &c, 1); emacs_write (selfds[1], &c, 1);
} }
unblock_input (); unblock_input ();
...@@ -4576,11 +4577,8 @@ - (void)fd_handler:(id)unused ...@@ -4576,11 +4577,8 @@ - (void)fd_handler:(id)unused
FD_SET (selfds[0], &fds); FD_SET (selfds[0], &fds);
result = select (selfds[0]+1, &fds, NULL, NULL, NULL); result = select (selfds[0]+1, &fds, NULL, NULL, NULL);
if (result > 0) if (result > 0 && read (selfds[0], &c, 1) == 1 && c == 'g')
{ waiting = 0;
read (selfds[0], &c, 1);
if (c == 'g') waiting = 0;
}
} }
else else
{ {
...@@ -4620,8 +4618,8 @@ - (void)fd_handler:(id)unused ...@@ -4620,8 +4618,8 @@ - (void)fd_handler:(id)unused
{ {
if (FD_ISSET (selfds[0], &readfds)) if (FD_ISSET (selfds[0], &readfds))
{ {
read (selfds[0], &c, 1); if (read (selfds[0], &c, 1) == 1 && c == 's')
if (c == 's') waiting = 1; waiting = 1;
} }
else else
{ {
...@@ -6696,7 +6694,7 @@ - (int) checkSamePosition: (int) position portion: (int) portion ...@@ -6696,7 +6694,7 @@ - (int) checkSamePosition: (int) position portion: (int) portion
/* Events may come here even if the event loop is not running. /* Events may come here even if the event loop is not running.
If we don't enter the event loop, the scroll bar will not update. If we don't enter the event loop, the scroll bar will not update.
So send SIGIO to ourselves. */ So send SIGIO to ourselves. */
if (apploopnr == 0) kill (0, SIGIO); if (apploopnr == 0) raise (SIGIO);
return self; return self;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment