all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: claudio.bley@gmail.com (Claudio Bley)
Cc: emacs-devel@gnu.org
Subject: Re: Calling 'select' from emacs_gnutls_pull
Date: Sat, 16 Feb 2013 18:52:23 +0200	[thread overview]
Message-ID: <83txpcqjzs.fsf@gnu.org> (raw)
In-Reply-To: <87fw0w6yny.fsf@lifelogs.com>

> From: Ted Zlatanov <tzz@lifelogs.com>
> 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.



  reply	other threads:[~2013-02-16 16:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-16 11:38 Calling 'select' from emacs_gnutls_pull Eli Zaretskii
2013-02-16 15:55 ` Ted Zlatanov
2013-02-16 16:52   ` Eli Zaretskii [this message]
2013-02-16 18:00     ` Ted Zlatanov
2013-02-16 19:30       ` Eli Zaretskii
2013-02-17 13:20         ` Ted Zlatanov
2013-02-22 11:15     ` Claudio Bley
2013-02-22 12:36       ` Eli Zaretskii
2013-02-22 15:17         ` Claudio Bley
2013-02-22 16:02           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83txpcqjzs.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=claudio.bley@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.