From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: gnutls infloop possibly fixed Date: Sat, 11 Feb 2012 21:48:08 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87ehu0lqc7.fsf@lifelogs.com> References: <87hayx8feo.fsf@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1329014903 17656 80.91.229.3 (12 Feb 2012 02:48:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 12 Feb 2012 02:48:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 12 03:48:23 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RwPUD-00070W-Oh for ged-emacs-devel@m.gmane.org; Sun, 12 Feb 2012 03:48:21 +0100 Original-Received: from localhost ([::1]:51473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwPUC-0000Fw-Nn for ged-emacs-devel@m.gmane.org; Sat, 11 Feb 2012 21:48:20 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:50070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwPU7-0000Fq-3L for emacs-devel@gnu.org; Sat, 11 Feb 2012 21:48:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwPU2-0001Oe-T9 for emacs-devel@gnu.org; Sat, 11 Feb 2012 21:48:15 -0500 Original-Received: from z.lifelogs.com ([173.255.230.239]:49929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwPU2-0001Oa-Nu for emacs-devel@gnu.org; Sat, 11 Feb 2012 21:48:10 -0500 Original-Received: from heechee (c-76-28-40-19.hsd1.vt.comcast.net [76.28.40.19]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: tzz) by z.lifelogs.com (Postfix) with ESMTPSA id D623C6E908 for ; Sun, 12 Feb 2012 02:48:09 +0000 (UTC) X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Mail-Copies-To: never Gmane-Reply-To-List: yes In-Reply-To: <87hayx8feo.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 11 Feb 2012 18:10:23 +0100") User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.0.93 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 173.255.230.239 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:148488 Archived-At: On Sat, 11 Feb 2012 18:10:23 +0100 Lars Ingebrigtsen wrote: LI> I finally took a hard look at the GnuTLS-related Emacs hangs. It turned LI> out to be pretty easy to reproduce for me. If I switch off the wifi on LI> this laptop and then presses `g' in Gnus, Emacs would reliably use 100% LI> CPU, and `C-g' or anything wouldn't work. So a totally dead Emacs. LI> I chased this down to emacs_gnutls_write, which would just, well, LI> infloop if libgnutls returned EAGAIN. I've now removed that, and just LI> leaves the normal Emacs process loop to retry if we get an EAGAIN. LI> This seems to work for me -- `C-g' reliably works for me if I drop the LI> network, or I get a new IP address. LI> There may be other side-effects, though. Slower throughput? I don't LI> know. Please give it a whirl and report back whether things stop LI> working or not. Thanks! I have just one question: can we, instead of aborting on EAGAIN, retry a few times? My suggestion is below. Maybe we could wait a millisecond, too. Or is all that handled at the Emacs process loop level? Thanks Ted === modified file 'src/gnutls.c' --- src/gnutls.c 2012-02-11 17:06:14 +0000 +++ src/gnutls.c 2012-02-12 02:46:24 +0000 @@ -341,6 +341,7 @@ EMACS_INT emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte) { + int retries = 10; ssize_t rtnval = 0; EMACS_INT bytes_written; gnutls_session_t state = proc->gnutls_state; @@ -365,6 +366,8 @@ { if (rtnval == GNUTLS_E_INTERRUPTED) continue; + if (rtnval == GNUTLS_E_AGAIN && retries-- > 0) + continue; else break; }