From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: error in server-running-p on M$ Date: Tue, 09 Dec 2008 15:46:31 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1228855634 29142 80.91.229.12 (9 Dec 2008 20:47:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2008 20:47:14 +0000 (UTC) Cc: Eli Zaretskii , Ulrich Mueller , emacs-devel@gnu.org To: "Juanma Barranquero" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 09 21:48:17 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LA9Uv-0005yP-EB for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 21:48:01 +0100 Original-Received: from localhost ([127.0.0.1]:43871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LA9Tj-0003m6-QN for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 15:46:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LA9Th-0003ly-1a for emacs-devel@gnu.org; Tue, 09 Dec 2008 15:46:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LA9Te-0003lW-F4 for emacs-devel@gnu.org; Tue, 09 Dec 2008 15:46:43 -0500 Original-Received: from [199.232.76.173] (port=35560 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LA9Te-0003lT-9n for emacs-devel@gnu.org; Tue, 09 Dec 2008 15:46:42 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:33627) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LA9Tb-0003ly-9A; Tue, 09 Dec 2008 15:46:39 -0500 Original-Received: from alfajor.home (vpn-132-204-232-230.acd.umontreal.ca [132.204.232.230]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id mB9KlCbP017569; Tue, 9 Dec 2008 15:47:12 -0500 Original-Received: by alfajor.home (Postfix, from userid 20848) id CC3351C91C; Tue, 9 Dec 2008 15:46:31 -0500 (EST) In-Reply-To: (Juanma Barranquero's message of "Mon, 24 Nov 2008 15:46:08 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Level: X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 2 Rules triggered PHISH_ACC_002=0.1, RV3165=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106738 Archived-At: > WDYT about the following patch? Looks good, tho see comment below. > ;; Delete the associated connection file, if applicable. > - ;; This is actually problematic: the file may have been overwritten by > - ;; another Emacs server in the mean time, so it's not ours any more. > - ;; (and (process-contact proc :server) > - ;; (eq (process-status proc) 'closed) > - ;; (ignore-errors (delete-file (process-get proc :server-file)))) > + (and (process-contact proc :server) > + (eq (process-status proc) 'closed) > + (ignore-errors (delete-file (process-get proc :server-file)))) > (server-log (format "Status changed to %s: %s" (process-status It would be good to keep some comment about the fact that we don't know for sure that the file is ours. > + (if (not (server-running-p server-name)) > + (ignore-errors (delete-file server-file)) > + (setq server-mode nil) ;; already set by the minor mode code > + (error "Server %S is already running" server-name)) As Ulrich points out, we should make sure that we can always somehow start a server. > - "Test whether server NAME is running." > + "Test whether server NAME is running. > +NOTE: This function is intended to be called from `server-start' > +and it is NOT 100% reliable." Just saying it's unreliable is not sufficient. We need to give some guarantee about what kind of incorrect result we may get. E.g. it could return t, nil, or `not-sure'. Also we should describe the reason for the unreliability: we prefer giving an immediate response over risking non-termination. Finally, for the purpose of server-start, we don't necessarily care if there is a server named "foo" running on some other machine, so maybe in the server-use-tcp case, if the IP is not 127.0.0.1, server-running-p might return a special value like `remote' and server-start might treat it like "not running" (i.e. it will remove the server-file). Stefan