emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100416: Fix bug #6237.


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100416: Fix bug #6237.
Date: Sat, 22 May 2010 22:09:51 +0300
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100416
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2010-05-22 22:09:51 +0300
message:
  Fix bug #6237.
  
   w32.c (sys_write): Break writes into chunks smaller than 32MB.
modified:
  src/ChangeLog
  src/w32.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-05-22 16:48:01 +0000
+++ b/src/ChangeLog     2010-05-22 19:09:51 +0000
@@ -1,3 +1,8 @@
+2010-05-22  Eli Zaretskii  <address@hidden>
+
+       * w32.c (sys_write): Break writes into chunks smaller than 32MB.
+       (Bug#6237)
+
 2010-05-22  Chong Yidong  <address@hidden>
 
        * image.c (Fimage_flush): Rename from image-refresh.

=== modified file 'src/w32.c'
--- a/src/w32.c 2010-05-01 18:28:00 +0000
+++ b/src/w32.c 2010-05-22 19:09:51 +0000
@@ -5700,7 +5700,34 @@
     }
   else
 #endif
-    nchars = _write (fd, buffer, count);
+    {
+      /* Some networked filesystems don't like too large writes, so
+        break them into smaller chunks.  See the Comments section of
+        the MSDN documentation of WriteFile for details behind the
+        choice of the value of CHUNK below.  See also the thread
+        http://thread.gmane.org/gmane.comp.version-control.git/145294
+        in the git mailing list.  */
+      const unsigned char *p = buffer;
+      const unsigned chunk = 30 * 1024 * 1024;
+
+      nchars = 0;
+      while (count > 0)
+       {
+         unsigned this_chunk = count < chunk ? count : chunk;
+         int n = _write (fd, p, this_chunk);
+
+         nchars += n;
+         if (n < 0)
+           {
+             nchars = n;
+             break;
+           }
+         else if (n < this_chunk)
+           break;
+         count -= n;
+         p += n;
+       }
+    }
 
   return nchars;
 }


reply via email to

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