unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: dgutov@yandex.ru
Cc: emacs-devel@gnu.org
Subject: Re: MS-Windows build using Posix configury
Date: Fri, 17 May 2013 21:43:47 +0300	[thread overview]
Message-ID: <83zjvtqwf0.fsf@gnu.org> (raw)
In-Reply-To: <831u95sdwi.fsf@gnu.org>

> Date: Fri, 17 May 2013 20:40:45 +0300
> Sun-Java-System-SMTP-Warning: Lines longer than SMTP allows found and
> 	truncated.
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > Looks like another good candidate for mentioning in INSTALL.MSYS.
> 
> I'd rather we unload all the DLLs before we exit, to avoid such
> problems in the first place.

Like in the patch below.  Can you try that?  (I hope you still have
that libintl-8.dll somewhere which required libgcc_s_dw2-1.dll, and
can reinstate it at least for the purposes of testing this patch.)

=== modified file 'src/w32.c'
--- src/w32.c	2013-04-15 13:39:41 +0000
+++ src/w32.c	2013-05-17 18:39:41 +0000
@@ -7404,13 +7404,9 @@ sys_localtime (const time_t *t)
 \f
 /* Try loading LIBRARY_ID from the file(s) specified in
    Vdynamic_library_alist.  If the library is loaded successfully,
-   return the handle of the DLL, and record the filename in the
-   property :loaded-from of LIBRARY_ID.  If the library could not be
-   found, or when it was already loaded (because the handle is not
-   recorded anywhere, and so is lost after use), return NULL.
-
-   We could also save the handle in :loaded-from, but currently
-   there's no use case for it.  */
+   return the handle of the DLL, and record the filename and the
+   handle in the property :loaded-from of LIBRARY_ID.  If the library
+   could not be found, or when it was already loaded, return NULL.  */
 HMODULE
 w32_delayed_load (Lisp_Object library_id)
 {
@@ -7434,11 +7430,12 @@ w32_delayed_load (Lisp_Object library_id
                 DWORD len;
 
                 len = GetModuleFileNameA (library_dll, name, sizeof (name));
-                found = Fcons (XCAR (dlls),
-                               (len > 0)
-                               /* Possibly truncated */
-                               ? make_specified_string (name, -1, len, 1)
-                               : Qnil);
+                found = list3 (XCAR (dlls),
+			       ((len > 0)
+				/* Possibly truncated */
+				? make_specified_string (name, -1, len, 1)
+				: Qnil),
+			       XIL ((EMACS_INT)library_dll));
                 break;
               }
           }
@@ -7449,6 +7446,36 @@ w32_delayed_load (Lisp_Object library_id
   return library_dll;
 }
 
+/* Unload any dynamic libraries we loaded.  Called at exit.  */
+static void
+unload_dlls (void)
+{
+  Lisp_Object dyn_alist = Vdynamic_library_alist;
+
+  while (CONSP (dyn_alist))
+    {
+      Lisp_Object elt = XCAR (dyn_alist), sym = Qnil;
+      Lisp_Object loaded_from = Qnil;
+
+      if (CONSP (elt))
+	{
+	  sym = XCAR (elt);
+	  if (SYMBOLP (sym))
+	    loaded_from = Fget (sym, QCloaded_from);
+	}
+
+      if (CONSP (loaded_from)
+	  && CONSP (XCDR (XCDR (loaded_from)))
+	  && INTEGERP (XCAR (XCDR (XCDR (loaded_from)))))
+	{
+	  HANDLE lh = (HANDLE)XLI (XCAR (XCDR (XCDR (loaded_from))));
+
+	  FreeLibrary (lh);
+	}
+      dyn_alist = XCDR (dyn_alist);
+    }
+}
+
 \f
 void
 check_windows_init_file (void)
@@ -7505,6 +7532,8 @@ term_ntproc (int ignored)
 {
   (void)ignored;
 
+  unload_dlls ();
+
   term_timers ();
 
   /* shutdown the socket interface if necessary */




  reply	other threads:[~2013-05-17 18:43 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 18:24 MS-Windows build using Posix configury Eli Zaretskii
2013-04-16 18:40 ` Eli Zaretskii
2013-04-16 20:13 ` Stefan Monnier
2013-04-17  2:53   ` Eli Zaretskii
2013-04-16 21:17 ` Glenn Morris
2013-04-17  2:56   ` Eli Zaretskii
2013-04-17  6:25     ` Glenn Morris
2013-04-17 16:48       ` Eli Zaretskii
2013-04-17 17:11         ` Glenn Morris
2013-04-17 17:34           ` Eli Zaretskii
2013-04-17 17:53             ` Glenn Morris
2013-04-17 18:15               ` Glenn Morris
2013-04-17 18:44                 ` Eli Zaretskii
2013-04-17  0:42 ` Glenn Morris
2013-04-17  2:57   ` Eli Zaretskii
2013-04-17  6:24     ` Glenn Morris
2013-04-17  3:33 ` Paul Eggert
2013-04-17 17:00   ` Eli Zaretskii
2013-04-17 18:48     ` Paul Eggert
2013-04-17 19:15       ` Glenn Morris
2013-04-17 19:45         ` Eli Zaretskii
2013-04-17 20:43           ` Glenn Morris
2013-04-17 21:19         ` Paul Eggert
2013-04-17 22:38           ` Glenn Morris
2013-04-18  0:52             ` Paul Eggert
2013-04-18  5:29               ` Glenn Morris
2013-04-18 16:11                 ` Eli Zaretskii
2013-04-17  6:27 ` Glenn Morris
2013-04-17  6:31 ` Glenn Morris
2013-04-18 19:32 ` Dani Moncayo
2013-04-18 20:27   ` Dani Moncayo
2013-04-18 21:20   ` Eli Zaretskii
2013-04-18 22:03     ` Dani Moncayo
2013-04-19  6:34       ` Eli Zaretskii
2013-04-19 20:17         ` Dani Moncayo
2013-04-20  6:34           ` Eli Zaretskii
2013-04-20  7:35             ` Dani Moncayo
2013-04-20  7:56               ` Eli Zaretskii
2013-04-20 17:18                 ` Dani Moncayo
2013-04-20 18:30                   ` Eli Zaretskii
2013-04-20 20:21                     ` Dani Moncayo
2013-04-21 15:12                       ` Eli Zaretskii
2013-04-21 19:53                         ` Dani Moncayo
2013-05-01 15:30                           ` Dani Moncayo
2013-05-01 16:30                             ` Eli Zaretskii
2013-05-01 19:30                               ` Dani Moncayo
2013-05-01 19:40                                 ` Eli Zaretskii
2013-05-02  6:43                                   ` Dani Moncayo
2013-05-02 16:19                                     ` Eli Zaretskii
2013-05-02 18:40                                       ` Dani Moncayo
2013-05-02 19:49                                         ` Eli Zaretskii
2013-05-02 21:42                                           ` Dani Moncayo
2013-05-02 21:43                                             ` Dani Moncayo
2013-05-03  8:50                                             ` Eli Zaretskii
2013-05-04 10:59                                               ` Dani Moncayo
2013-05-04 11:04                                                 ` Dani Moncayo
2013-05-04 11:27                                                 ` Eli Zaretskii
2013-05-04 12:00                                                   ` Dani Moncayo
2013-05-04 12:30                                                     ` Eli Zaretskii
2013-05-07 19:36                                                       ` Dani Moncayo
2013-05-07 21:13                                                         ` Eli Zaretskii
2013-05-07 22:04                                                           ` Dani Moncayo
2013-05-08 17:09                                                             ` Eli Zaretskii
2013-05-08 17:32                                                               ` Dani Moncayo
2013-05-13 12:23                                                               ` Andy Moreton
2013-05-13 16:23                                                                 ` Eli Zaretskii
2013-05-16  6:00                                                                   ` Eli Zaretskii
2013-05-16  6:31                                                                     ` Paul Eggert
2013-05-16  6:56                                                                       ` Eli Zaretskii
2013-05-16  7:16                                                                         ` Paul Eggert
2013-05-16  7:30                                                                           ` Eli Zaretskii
2013-05-16 13:19                                                                     ` Eli Zaretskii
2013-05-16 14:43                                                                       ` Dmitry Gutov
2013-05-16 15:41                                                                         ` Eli Zaretskii
2013-05-16 16:10                                                                           ` Dmitry Gutov
2013-05-16 17:17                                                                             ` Dani Moncayo
2013-05-16 17:54                                                                               ` Eli Zaretskii
2013-05-16 18:01                                                                                 ` Dani Moncayo
2013-05-16 18:36                                                                                   ` Eli Zaretskii
2013-05-16 21:02                                                                                 ` Dmitry Gutov
2013-05-17  6:02                                                                                   ` Eli Zaretskii
2013-05-16 17:18                                                                             ` Eli Zaretskii
2013-05-16 21:19                                                                               ` Dmitry Gutov
2013-05-17  9:39                                                                                 ` Eli Zaretskii
2013-05-17 12:05                                                                                   ` Dmitry Gutov
2013-05-17 13:13                                                                                     ` Eli Zaretskii
2013-05-17 14:03                                                                                       ` Dmitry Gutov
2013-05-17 14:26                                                                                         ` Eli Zaretskii
2013-05-17 15:29                                                                                           ` Dmitry Gutov
2013-05-17 16:05                                                                                             ` Eli Zaretskii
2013-05-17 16:30                                                                                               ` Dmitry Gutov
2013-05-17 17:40                                                                                                 ` Eli Zaretskii
2013-05-17 18:43                                                                                                   ` Eli Zaretskii [this message]
2013-05-17 20:47                                                                                                     ` Dmitry Gutov
2013-05-18  7:18                                                                                                       ` Eli Zaretskii
2013-05-18  8:08                                                                                                         ` Dmitry Gutov
2013-05-18  9:08                                                                                                           ` Eli Zaretskii
2013-05-18 13:24                                                                                                             ` Dmitry Gutov
2013-05-18 14:25                                                                                                               ` Eli Zaretskii
2013-05-18 14:28                                                                                                                 ` Dmitry Gutov
2013-05-18 18:21                                                                                                                   ` Eli Zaretskii
2013-05-18 18:42                                                                                                                     ` Dmitry Gutov
2013-05-18 18:53                                                                                                                       ` Eli Zaretskii
2013-05-18 19:15                                                                                                                         ` Dmitry Gutov
2013-05-18 19:24                                                                                                                           ` Eli Zaretskii
2013-06-07  8:51                                                                                                                           ` Eli Zaretskii
2013-06-07  9:36                                                                                                                             ` Dmitry Gutov
2013-06-07  9:56                                                                                                                               ` Eli Zaretskii
2013-05-19  6:48                                                                         ` Stephen Leake
2013-05-19 14:51                                                                           ` Eli Zaretskii
2013-05-21  8:31                                                                             ` Stephen Leake
2013-05-21 17:07                                                                               ` Eli Zaretskii
2013-05-21 19:36                                                                                 ` Stephen Leake
2013-05-25  7:29                                                                                   ` Eli Zaretskii
2013-04-19  3:05 ` Ken Brown
2013-04-19  6:35   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83zjvtqwf0.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).