From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#19688: [patch] add support for emacs daemon on Windows Date: Mon, 26 Jan 2015 08:00:37 +0200 Message-ID: <83d262qdx6.fsf@gnu.org> References: <83h9ver459.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1422252073 20805 80.91.229.3 (26 Jan 2015 06:01:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Jan 2015 06:01:13 +0000 (UTC) Cc: 19688@debbugs.gnu.org To: Mark Laws Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 26 07:01:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1YFcjW-0005Y1-PF for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jan 2015 07:01:10 +0100 Original-Received: from localhost ([::1]:40053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFcjW-0006Yu-2t for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jan 2015 01:01:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFcjS-0006Yn-HH for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 01:01:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFcjO-0001xT-Gx for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 01:01:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFcjO-0001xP-Dr for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 01:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YFcjO-00084w-5h for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 01:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Jan 2015 06:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 19688-submit@debbugs.gnu.org id=B19688.142225206131040 (code B ref 19688); Mon, 26 Jan 2015 06:01:02 +0000 Original-Received: (at 19688) by debbugs.gnu.org; 26 Jan 2015 06:01:01 +0000 Original-Received: from localhost ([127.0.0.1]:56468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFcjM-00084Z-OO for submit@debbugs.gnu.org; Mon, 26 Jan 2015 01:01:01 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:53359) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFcjK-00084J-AZ for 19688@debbugs.gnu.org; Mon, 26 Jan 2015 01:00:59 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NIR00K00SKIZS00@a-mtaout22.012.net.il> for 19688@debbugs.gnu.org; Mon, 26 Jan 2015 08:00:51 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NIR00KKWSPET570@a-mtaout22.012.net.il>; Mon, 26 Jan 2015 08:00:51 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98741 Archived-At: [Please keep the bug address on the CC list, so that this whole discussion gets archived.] > Date: Mon, 26 Jan 2015 08:16:38 +0900 > From: Mark Laws > > >> +#define W32_EMACS_SERVER_GUID "{0B8E5DCB-D7CF-4423-A9F1-2F6927F0D318}" > > > > Where did this GUID come from? > > > I generated it myself. Is that safe? Do we care whether this GUID is globally unique? Why exactly do we need it to begin with? > Moved to ms-w32.h and removed changes relating to the header. Thanks. > >> +#else > >> +bool w32_is_daemon; > >> +bool w32_daemon_is_initialized; > >> +static HANDLE w32_daemon_event; > >> +#endif > > > > Why do we need anything beyond the event handle? Can't it serve > > double duty as a flag as well? We could use INVALID_HANDLE_VALUE > > and/or NULL as distinct values with specific meanings. > > I've reworked it to use only w32_daemon_event. One minor issue: to > avoid including any Windows-related headers in lisp.h, the extern > declaration of w32_daemon_event there is void* instead of HANDLE. I > doubt the type of HANDLE will ever change, so it shouldn't matter > much. That should be fine, but there's no need to have the handle in lisp.h, either. We could put it on w32.h, for example, which is already included by emacs.c and other files. If w32.h doesn't fit the bill, please try to find some other w32*.h which does. > >> +#ifndef WINDOWSNT > >> /* Make sure IS_DAEMON starts up as false. */ > >> daemon_pipe[1] = 0; > >> +#endif > > > > You should do a similar initialization on WINDOWSNT, to avoid using > > the value that was initialized when Emacs was dumped. > > I'm not sure I understand. Do you mean for w32_daemon_event? If so, it > should already always be zero when Emacs starts up. It might not be zero. Recall that Emacs is run during the build process, when it executes some code, and then "dumps itself", which involves writing portions of its memory to a disk file that thereafter becomes the emacs.exe you run normally. If, for some reason, w32_daemon_event is initialized in this first instance, it will not be zero in the dumped image. So we always re-initialize such variables explicitly, instead of relying on the linker initializations. You can see that in the sources, and that is also the reason why the Posix code initializes daemon_pipe[1]. > > Also, the call to daemon_check_preconditions should be outside of the > > #ifdef, as it is used on all platforms. > > daemon_check_preconditions already gets called for both WINDOWSNT and > !WINDOWSNT (see the #else). If we move it outside the #ifdef to > eliminate having to mention it for both cases, then "nfd" and "err" > will also have to be outside the ifdef in order to be compatible with > strict pre-C99 compilers that only accept variable declarations at the > beginning of blocks. C99 compliant compiler is a prerequisite in the development version of Emacs, so this problem doesn't exist. Thanks.