bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: immutable: Implement on native Windows


From: Gisle Vanem
Subject: Re: immutable: Implement on native Windows
Date: Mon, 18 Jan 2021 17:52:00 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Bruno Haible wrote:

The 'immutable' module, so far, worked only on platforms with mmap() and
mprotect(). With this patch, it also works on native Windows.
...

+  if (!CloseHandle (h))
+    {
+      UnmapViewOfFile (mem_w);
+      UnmapViewOfFile (mem_r);
+      CloseHandle (h);
+      return 0;
+    }
+# else
    /* Extend the file by size/pagesize pages.  */
    long new_file_length = file_length + size;
    if (ftruncate (file_fd, new_file_length) < 0)

These functions look really nice. I've yet to try them.

I noted FileZilla have similar code in 'aio.cpp', but with
handling of a macOS bug if that is something Gnulib should
handle too:

  #if FZ_MAC
    // There's a bug on macOS: ftruncate can only be called _once_ on a shared 
memory object.
    // The manpages do not cover this bug, only XNU's bsd/kern/posix_shm.c 
mentions it.
    struct stat s;
    if (fstat(shm, &s) != 0) {
      int err = errno;
      engine_.GetLogger().log(logmsg::debug_warning, "fstat failed with error 
%d", err);
      return false;
    }
    if (s.st_size < 0 || static_cast<size_t>(s.st_size) < memory_size_)
  #endif
  // .. then the rest is similar to yours.


Not sure if the "bug" is still there, but the
is code at:
  
https://svn.filezilla-project.org/filezilla/FileZilla3/trunk/src/engine/aio.cpp?view=markup#l84

--
--gv





reply via email to

[Prev in Thread] Current Thread [Next in Thread]