diff options
| author | Paul Eggert | 2014-03-04 22:31:57 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-03-04 22:31:57 -0800 |
| commit | e6e8a5eb4dadbf5a0e7949a4aee6eab3dc5dec2d (patch) | |
| tree | 4400bf6d6d6cb3fe3f7cf46e9b7935894bd65376 /src | |
| parent | d2f720acf5dbf40a838df4b09cd410034d0f6149 (diff) | |
| download | emacs-e6e8a5eb4dadbf5a0e7949a4aee6eab3dc5dec2d.tar.gz emacs-e6e8a5eb4dadbf5a0e7949a4aee6eab3dc5dec2d.zip | |
Fix "resource temporarily unavailable" with xgselect.
* xgselect.c: Include <stdbool.h>.
(xg_select) [!USE_GTK]: Don't lose track of errno.
Fixes: debbugs:16925
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/xgselect.c | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f5a02483430..22830f49fb8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2014-03-05 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2014-03-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Fix "resource temporarily unavailable" with xgselect (Bug#16925). | ||
| 4 | * xgselect.c: Include <stdbool.h>. | ||
| 5 | (xg_select) [!USE_GTK]: Don't lose track of errno. | ||
| 6 | |||
| 3 | Fix minor --enable-gcc-warnings issues. | 7 | Fix minor --enable-gcc-warnings issues. |
| 4 | * widget.c (update_various_frame_slots, EmacsFrameResize): | 8 | * widget.c (update_various_frame_slots, EmacsFrameResize): |
| 5 | Avoid unused locals. Prefer 'if' to '#if' when either will do. | 9 | Avoid unused locals. Prefer 'if' to '#if' when either will do. |
diff --git a/src/xgselect.c b/src/xgselect.c index a281414610a..1d3f916c9f8 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -25,6 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 25 | 25 | ||
| 26 | #include <glib.h> | 26 | #include <glib.h> |
| 27 | #include <errno.h> | 27 | #include <errno.h> |
| 28 | #include <stdbool.h> | ||
| 28 | #include <timespec.h> | 29 | #include <timespec.h> |
| 29 | #include "frame.h" | 30 | #include "frame.h" |
| 30 | 31 | ||
| @@ -43,6 +44,7 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds, | |||
| 43 | int gfds_size = sizeof gfds_buf / sizeof *gfds_buf; | 44 | int gfds_size = sizeof gfds_buf / sizeof *gfds_buf; |
| 44 | int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1; | 45 | int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1; |
| 45 | int i, nfds, tmo_in_millisec; | 46 | int i, nfds, tmo_in_millisec; |
| 47 | bool need_to_dispatch; | ||
| 46 | USE_SAFE_ALLOCA; | 48 | USE_SAFE_ALLOCA; |
| 47 | 49 | ||
| 48 | /* Do not try to optimize with an initial check with g_main_context_pending | 50 | /* Do not try to optimize with an initial check with g_main_context_pending |
| @@ -127,10 +129,17 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds, | |||
| 127 | /* If Gtk+ is in use eventually gtk_main_iteration will be called, | 129 | /* If Gtk+ is in use eventually gtk_main_iteration will be called, |
| 128 | unless retval is zero. */ | 130 | unless retval is zero. */ |
| 129 | #ifdef USE_GTK | 131 | #ifdef USE_GTK |
| 130 | if (retval == 0) | 132 | need_to_dispatch = retval == 0; |
| 133 | #else | ||
| 134 | need_to_dispatch = true; | ||
| 131 | #endif | 135 | #endif |
| 132 | while (g_main_context_pending (context)) | 136 | if (need_to_dispatch) |
| 133 | g_main_context_dispatch (context); | 137 | { |
| 138 | int pselect_errno = errno; | ||
| 139 | while (g_main_context_pending (context)) | ||
| 140 | g_main_context_dispatch (context); | ||
| 141 | errno = pselect_errno; | ||
| 142 | } | ||
| 134 | 143 | ||
| 135 | /* To not have to recalculate timeout, return like this. */ | 144 | /* To not have to recalculate timeout, return like this. */ |
| 136 | if ((our_fds > 0 || (nfds == 0 && tmop == &tmo)) && (retval == 0)) | 145 | if ((our_fds > 0 || (nfds == 0 && tmop == &tmo)) && (retval == 0)) |