From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Calling 'select' from emacs_gnutls_pull Date: Sat, 16 Feb 2013 18:52:23 +0200 Message-ID: <83txpcqjzs.fsf@gnu.org> References: <83wqu8qyik.fsf@gnu.org> <87fw0w6yny.fsf@lifelogs.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1361033587 3715 80.91.229.3 (16 Feb 2013 16:53:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Feb 2013 16:53:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: claudio.bley@gmail.com (Claudio Bley) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 16 17:53:27 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U6l0p-0005Or-JW for ged-emacs-devel@m.gmane.org; Sat, 16 Feb 2013 17:53:19 +0100 Original-Received: from localhost ([::1]:52114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6l0V-0007yT-PV for ged-emacs-devel@m.gmane.org; Sat, 16 Feb 2013 11:52:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:51496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6l0O-0007vt-AX for emacs-devel@gnu.org; Sat, 16 Feb 2013 11:52:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6l0M-0001K0-Lf for emacs-devel@gnu.org; Sat, 16 Feb 2013 11:52:52 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:35152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6l0M-0001Jr-Dj for emacs-devel@gnu.org; Sat, 16 Feb 2013 11:52:50 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MIB00200O0U6C00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Sat, 16 Feb 2013 18:52:21 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MIB001G4O78WMA0@a-mtaout22.012.net.il>; Sat, 16 Feb 2013 18:52:20 +0200 (IST) In-reply-to: <87fw0w6yny.fsf@lifelogs.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:157082 Archived-At: > From: Ted Zlatanov > 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.