From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/65198 Path: news.gmane.org!not-for-mail From: Elias Oltmanns Newsgroups: gmane.emacs.gnus.general Subject: Canonical server names and the false assumption in g-s-named-server (was: Shouldn't agentised servers be switched offline in unplugged mode?) Date: Mon, 17 Sep 2007 00:37:10 +0200 Message-ID: <87ejgytey1.fsf@denkblock.local> References: <87zlzxyyxs.fsf@denkblock.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1189982288 3765 80.91.229.12 (16 Sep 2007 22:38:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 16 Sep 2007 22:38:08 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M13711@lists.math.uh.edu Mon Sep 17 00:38:07 2007 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1IX2kb-0002lp-O2 for ding-account@gmane.org; Mon, 17 Sep 2007 00:38:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1IX2kN-0002r9-H3; Sun, 16 Sep 2007 17:37:47 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1IX2kM-0002qt-07 for ding@lists.math.uh.edu; Sun, 16 Sep 2007 17:37:46 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.67) (envelope-from ) id 1IX2kH-00062f-LZ for ding@lists.math.uh.edu; Sun, 16 Sep 2007 17:37:45 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1IX2k8-0000Eh-00 for ; Mon, 17 Sep 2007 00:37:32 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IX2k2-0002Yi-Qw for ding@gnus.org; Mon, 17 Sep 2007 00:37:26 +0200 Original-Received: from pd9e84be8.dip.t-dialin.net ([217.232.75.232]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Sep 2007 00:37:26 +0200 Original-Received: from eo by pd9e84be8.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Sep 2007 00:37:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 137 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pd9e84be8.dip.t-dialin.net User-Agent: Gnus/5.110007 (No Gnus v0.7) Cancel-Lock: sha1:dKc85OMzwp/fGBdCAyZ17BMDylM= X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:65198 Archived-At: --=-=-= Elias Oltmanns wrote: > Hi again, > > currently, after I have downloaded articles from a server and switched > into unplugged operation, aell agentised servers remains open in a > sense, i.e., when I enter a group served by any of those servers, gnus > tries to connect to the server and if it succeeds, treats it as any > other open server. Only if the connection fails, the server is switched > offline. I wonder whether this really is a desirable behaviour. > Personally, I clearly prefer gnus to behave "unplugged" as it tells me > in the mode line. If I really want to open one of those servers, I can > still do so explicitly in the server buffer. Also, the current behaviour > should be rather annoying in an dial-on-demand setup. Shouldn't > gnus-agent-close-connections switch all agentised servers offline? As it turns out, the problem is a somewhat more subtle one. Mind you, I still think that it would be a sensible idea to switch agentised servers offline in gnus-agent-close-connections, if only to make sure that they show up correctly (that is, with status flag "(offline)") in the server buffer right after switching to unplugged mode. However, the behaviour I described in my original mail is due to another problem. As a matter of fact, gnus currently doesn't reliably recognise agentised servers, or, more precisely, sometimes a method is improperly considered not covered by the agent. The problem is this: gnus-agent-covered-methods, sadly, doesn't store methods but only server names. Well, this approach requires the notion of a canonical server name. For that purpose, gnus-server-named-server determines the name of a server by feeding its method to gnus-method-to-server and so should gnus-agent-method-p. Unfortunately, there is a flaw in this concept since gnus-method-to-server consults gnus-server-method-cache and returns the first entry matching the method. Supposing gnus-server-alist contains an entry like this: ("provider" nnimap "provider" (nnimap-server-address "imap.provider.com") then gnus-server-method-cache will eventually, depending on the sequence of events, contain entries like this: (... ("nnimap:provider" nnimap "provider" (nnimap-server-address "imap.provider.com") ... ("provider" nnimap "provider" (nnimap-server-address "imap.provider.com") ...) So, the result of gnus-method-to-server is not predictable for any given method if it is in the cache. For these reasons I suggest to apply the patch attached below. Actually, I'd prefer to have gnus-agent-covered-methods store methods rather than servers, but I suppose that this will introduce more problems with existing installations upgrading to the next release of gnus. Regards, Elias Applies to current trunk: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=method-to-server.patch Index: lisp/gnus-srvr.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-srvr.el,v retrieving revision 7.30 diff -u -r7.30 gnus-srvr.el --- lisp/gnus-srvr.el 31 Jul 2007 03:58:31 -0000 7.30 +++ lisp/gnus-srvr.el 15 Sep 2007 21:50:01 -0000 @@ -280,7 +280,7 @@ ;; Insert the text. (eval gnus-server-line-format-spec)) (list 'gnus-server (intern gnus-tmp-name) - 'gnus-named-server (intern (gnus-method-to-server method)))))) + 'gnus-named-server (intern (gnus-method-to-server method t)))))) (defun gnus-enter-server-buffer () "Set up the server buffer." Index: lisp/gnus.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus.el,v retrieving revision 7.69 diff -u -r7.69 gnus.el --- lisp/gnus.el 13 Sep 2007 22:30:42 -0000 7.69 +++ lisp/gnus.el 15 Sep 2007 21:50:08 -0000 @@ -3518,15 +3518,16 @@ (nth 1 method)))) method))) -(defsubst gnus-method-to-server (method) +(defsubst gnus-method-to-server (method &optional nocache) (catch 'server-name (setq method (or method gnus-select-method)) ;; Perhaps it is already in the cache. - (mapc (lambda (name-method) - (if (equal (cdr name-method) method) - (throw 'server-name (car name-method)))) - gnus-server-method-cache) + (unless nocache + (mapc (lambda (name-method) + (if (equal (cdr name-method) method) + (throw 'server-name (car name-method)))) + gnus-server-method-cache)) (mapc (lambda (server-alist) @@ -4252,14 +4253,16 @@ ;;; Agent functions -(defun gnus-agent-method-p (method) +(defun gnus-agent-method-p (method-or-server) "Say whether METHOD is covered by the agent." - (or (eq (car gnus-agent-method-p-cache) method) - (setq gnus-agent-method-p-cache - (cons method - (member (if (stringp method) - method - (gnus-method-to-server method)) gnus-agent-covered-methods)))) + (or (eq (car gnus-agent-method-p-cache) method-or-server) + (let* ((method (if (stringp method-or-server) + (gnus-server-to-method method-or-server) + method-or-server)) + (server (gnus-method-to-server method t))) + (setq gnus-agent-method-p-cache + (cons method-or-server + (member server gnus-agent-covered-methods))))) (cdr gnus-agent-method-p-cache)) (defun gnus-online (method) --=-=-=--