unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* w32-find-bdf-fonts does not close file handles of files examined
@ 2007-06-20 20:28 Michael Schierl
  2007-06-20 21:29 ` Jason Rumney
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Schierl @ 2007-06-20 20:28 UTC (permalink / raw)
  To: bug-gnu-emacs

Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:


Start with emacs -Q and run this code:

(let* ((tmpdir (make-temp-file "bugdir-" t))
       (tmpfile (expand-file-name "dummy.bdf" tmpdir)))
  (with-current-buffer (find-file-noselect tmpfile)
    (insert "STARTFONT 2.1\n")
    (save-buffer 0))
  (w32-find-bdf-fonts tmpdir)
  (delete-file tmpfile)
  (delete-directory tmpdir))

It will signal an error at delete-file because it cannot delete the
given file. When removing the w32-find-bdf-fonts call, everything works
as expected. This is annoying if you want to test new bdf fonts on
Windows, because if you do not like them you cannot delete them until
Emacs is closed (and Windows will close all file handles). It is okay to
keep the file open while in use, but it should IMHO be closed if not used.


In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
 of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: DEU
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  encoded-kbd-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
M-x r e p o r t - e m a c s - b u g <return>

Recent messages:
("D:\\Progs\\emacs\\bin\\emacs.exe" "-Q")
Loading encoded-kb...done
For information about the GNU Project and its goals, type C-h C-p.
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: w32-find-bdf-fonts does not close file handles of files examined
  2007-06-20 20:28 w32-find-bdf-fonts does not close file handles of files examined Michael Schierl
@ 2007-06-20 21:29 ` Jason Rumney
  2007-06-22 12:51   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Rumney @ 2007-06-20 21:29 UTC (permalink / raw)
  To: Michael Schierl; +Cc: bug-gnu-emacs

Michael Schierl wrote:
> Start with emacs -Q and run this code:
>
> (let* ((tmpdir (make-temp-file "bugdir-" t))
>        (tmpfile (expand-file-name "dummy.bdf" tmpdir)))
>   (with-current-buffer (find-file-noselect tmpfile)
>     (insert "STARTFONT 2.1\n")
>     (save-buffer 0))
>   (w32-find-bdf-fonts tmpdir)
>   (delete-file tmpfile)
>   (delete-directory tmpdir))
>
> It will signal an error at delete-file because it cannot delete the
> given file.

Thanks for the report. I have fixed this in the Emacs 22 branch now.
Although the file was being closed, it was still mapped into memory, so
the OS was keeping it open.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: w32-find-bdf-fonts does not close file handles of files examined
  2007-06-20 21:29 ` Jason Rumney
@ 2007-06-22 12:51   ` Eli Zaretskii
  2007-06-22 13:22     ` Jason Rumney
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2007-06-22 12:51 UTC (permalink / raw)
  To: Jason Rumney; +Cc: bug-gnu-emacs

> Date: Wed, 20 Jun 2007 22:29:07 +0100
> From: Jason Rumney <jasonr@gnu.org>
> Cc: bug-gnu-emacs@gnu.org
> 
> Michael Schierl wrote:
> > Start with emacs -Q and run this code:
> >
> > (let* ((tmpdir (make-temp-file "bugdir-" t))
> >        (tmpfile (expand-file-name "dummy.bdf" tmpdir)))
> >   (with-current-buffer (find-file-noselect tmpfile)
> >     (insert "STARTFONT 2.1\n")
> >     (save-buffer 0))
> >   (w32-find-bdf-fonts tmpdir)
> >   (delete-file tmpfile)
> >   (delete-directory tmpdir))
> >
> > It will signal an error at delete-file because it cannot delete the
> > given file.
> 
> Thanks for the report. I have fixed this in the Emacs 22 branch now.
> Although the file was being closed, it was still mapped into memory, so
> the OS was keeping it open.

Btw, why are we using memory-mapped files for this functionality?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: w32-find-bdf-fonts does not close file handles of files examined
  2007-06-22 12:51   ` Eli Zaretskii
@ 2007-06-22 13:22     ` Jason Rumney
  2007-06-22 17:58       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Rumney @ 2007-06-22 13:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bug-gnu-emacs

Eli Zaretskii wrote:
> Btw, why are we using memory-mapped files for this functionality?
>   

It predates the inclusion of w32bdf.c in Emacs (the implementation is
based on mw32bdf.c from Meadow, a Japanese fork of Emacs 20), but I
think the reason for using memory mapping is that some East Asian fonts
are very large, and ten years ago when this code was written, the
difference between reading a file into memory and mapping it mattered a
lot more. I can see that in this particular function where the file is
closed again immediately, it offers no advantage, and is actually a loss
on Windows 9X, which doesn't support swapping directly from
memory-mapped files, but the new font backend in Emacs 23 will
eventually replace this code anyway, so there is not much point in
making major changes now.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: w32-find-bdf-fonts does not close file handles of files examined
  2007-06-22 13:22     ` Jason Rumney
@ 2007-06-22 17:58       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2007-06-22 17:58 UTC (permalink / raw)
  To: Jason Rumney; +Cc: bug-gnu-emacs

> Date: Fri, 22 Jun 2007 14:22:20 +0100
> From: Jason Rumney <jasonr@gnu.org>
> Cc: bug-gnu-emacs@gnu.org
> 
> Eli Zaretskii wrote:
> > Btw, why are we using memory-mapped files for this functionality?
> >   
> 
> It predates the inclusion of w32bdf.c in Emacs (the implementation is
> based on mw32bdf.c from Meadow, a Japanese fork of Emacs 20), but I
> think the reason for using memory mapping is that some East Asian fonts
> are very large, and ten years ago when this code was written, the
> difference between reading a file into memory and mapping it mattered a
> lot more. I can see that in this particular function where the file is
> closed again immediately, it offers no advantage, and is actually a loss
> on Windows 9X, which doesn't support swapping directly from
> memory-mapped files, but the new font backend in Emacs 23 will
> eventually replace this code anyway, so there is not much point in
> making major changes now.

Thanks for the explanation.  I wondered about this precisely because
we close the file immediately.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-06-22 17:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-20 20:28 w32-find-bdf-fonts does not close file handles of files examined Michael Schierl
2007-06-20 21:29 ` Jason Rumney
2007-06-22 12:51   ` Eli Zaretskii
2007-06-22 13:22     ` Jason Rumney
2007-06-22 17:58       ` Eli Zaretskii

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).