summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen <larsi@gnus.org>2011-11-21 19:21:42 +0100
committerLars Magne Ingebrigtsen <larsi@gnus.org>2011-11-21 19:21:42 +0100
commit261b6fd466a835692e0b1eedba327eb674d79ca6 (patch)
treeffb661c6201f408aa01ab00fb3e5acd883532486
parente7cfd277bd7b5fda95431481c027fb16023cc654 (diff)
downloademacs-261b6fd466a835692e0b1eedba327eb674d79ca6.tar.gz
Fix asynchrounous GnuTLS socket handling on some versions of the GnuTLS library.
Some versions of the GnuTLS library doesn't respons to poll reliably. Work around this by checking all GnuTLS sockets explicitly from the idle loop.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/process.c42
2 files changed, 38 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ef9aa4a907f..45e8eb1025d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-21 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * process.c (wait_reading_process_output): Fix asynchrounous
+ GnuTLS socket handling on some versions of the GnuTLS library.
+
2011-11-21 Jan Djärv <jan.h.d@swipnet.se>
* xterm.c (x_clear_frame): Reinstate the XClearWindow call.
diff --git a/src/process.c b/src/process.c
index bea9e72019b..02eb1122a07 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4620,15 +4620,39 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
some data in the TCP buffers so that select works, but
with custom pull/push functions we need to check if some
data is available in the buffers manually. */
- if (nfds == 0 &&
- wait_proc && wait_proc->gnutls_p /* Check for valid process. */
- /* Do we have pending data? */
- && emacs_gnutls_record_check_pending (wait_proc->gnutls_state) > 0)
- {
- nfds = 1;
- /* Set to Available. */
- FD_SET (wait_proc->infd, &Available);
- }
+ if (nfds == 0)
+ {
+ if (! wait_proc)
+ {
+ /* We're not waiting on a specific process, so loop
+ through all the channels and check for data. */
+ struct Lisp_Process *proc;
+ for (channel = 0; channel < MAXDESC; ++channel)
+ {
+ if (! NILP (chan_process[channel]) &&
+ (proc = XPROCESS (chan_process[channel])) != NULL &&
+ proc->gnutls_p &&
+ proc->infd &&
+ emacs_gnutls_record_check_pending (proc->gnutls_state) > 0)
+ {
+ nfds++;
+ FD_SET (proc->infd, &Available);
+ }
+ }
+ }
+ else
+ {
+ /* Check this specific channel. */
+ if (wait_proc->gnutls_p && /* Check for valid process. */
+ /* Do we have pending data? */
+ emacs_gnutls_record_check_pending (wait_proc->gnutls_state) > 0)
+ {
+ nfds = 1;
+ /* Set to Available. */
+ FD_SET (wait_proc->infd, &Available);
+ }
+ }
+ }
#endif
}