[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling 'select' from emacs_gnutls_pull
From: |
Eli Zaretskii |
Subject: |
Re: Calling 'select' from emacs_gnutls_pull |
Date: |
Sat, 16 Feb 2013 18:52:23 +0200 |
> From: Ted Zlatanov <address@hidden>
> Date: Sat, 16 Feb 2013 10:55:45 -0500
>
> ...and there are comments accumulated over the years in that
> neighborhood. Claudio Bley contributed much of the original code here,
> including the piece you're referring to. The history is at
>
> http://comments.gmane.org/gmane.emacs.devel/136816
I've (re-)read that thread, but didn't find any rationale for calling
'select'. Claudio, could you perhaps chime in?
> I think you're correct, but remember the GnuTLS library is calling these
> functions.
But GnuTLS calls these functions because Emacs called
'emacs_gnutls_read', right? Which seems to be just a fancy way of
reading from a socket, as far as Emacs is concerned, as this fragment
from 'read_process_output', a subroutine of 'wait_reading_process_output',
seems to indicate:
#ifdef HAVE_GNUTLS
if (p->gnutls_p)
nbytes = emacs_gnutls_read (p, chars + carryover + buffered,
readmax - buffered);
else
#endif
nbytes = emacs_read (channel, chars + carryover + buffered,
readmax - buffered);
Here, 'emacs_read' (on Windows) just calls 'sys_read'. But
'emacs_gnutls_read', via 'emacs_gnutls_pull', in addition also calls
'select', and I wonder why this difference is necessary.
> So I don't know if it would make sense to let the Emacs
> reader thread handle the socket management, because we could end up with
> poor performance or even contention.
We already use the Emacs reader threads for that. And it works well
enough for sockets. In a nutshell, the reader thread does blocking
reads from the socket, while 'sys_read' (called by Emacs as 'read')
emulates non-blocking reads, by looking at the status set by the
reader thread.
> if I can help simulate this condition or test some possible
> solutions, I'll be glad to assist.
Thanks. It would be good if you (or someone else) could describe a
simple setup for reading stuff via GnuTLS from some URL, which I could
then try on my machine under a debugger.
- Calling 'select' from emacs_gnutls_pull, Eli Zaretskii, 2013/02/16
- Re: Calling 'select' from emacs_gnutls_pull, Ted Zlatanov, 2013/02/16
- Re: Calling 'select' from emacs_gnutls_pull,
Eli Zaretskii <=
- Re: Calling 'select' from emacs_gnutls_pull, Claudio Bley, 2013/02/22
- Re: Calling 'select' from emacs_gnutls_pull, Eli Zaretskii, 2013/02/22
- Re: Calling 'select' from emacs_gnutls_pull, Claudio Bley, 2013/02/22
- Re: Calling 'select' from emacs_gnutls_pull, Eli Zaretskii, 2013/02/22