git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix checkout of large files to network shares under Windows XP
@ 2010-04-19 12:45 Sebastian Schuberth
  2010-04-19 20:41 ` Junio C Hamano
  2010-04-19 20:43 ` René Scharfe
  0 siblings, 2 replies; 15+ messages in thread
From: Sebastian Schuberth @ 2010-04-19 12:45 UTC (permalink / raw)
  To: git; +Cc: msysgit

This fixes msysGit issue 409, see
http://code.google.com/p/msysgit/issues/detail?id=409

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 compat/mingw.c |   24 ++++++++++++++++++++++++
 compat/mingw.h |    3 +++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index 7ec615c..672d074 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -293,6 +293,30 @@ int mingw_open (const char *filename, int oflags, ...)
 	return fd;
 }
 
+#undef write
+ssize_t mingw_write(int fd, const void *buf, size_t count)
+{
+	ssize_t written = 0;
+	size_t total = 0, size = count;
+
+	while (total < count && size > 0) {
+		written = write(fd, buf, size);
+		if (written < 0 && errno == EINVAL) {
+			// There seems to be a bug in the Windows XP network stack that
+			// causes writes with sizes > 64 MB to fail, so we halve the size
+			// until we succeed or ultimately fail.
+			size /= 2;
+		} else {
+			buf += written;
+			total += written;
+			if (total + size > count)
+				size = count - total;
+		}
+	}
+
+	return written < 0 ? written : total;
+}
+
 #undef fopen
 FILE *mingw_fopen (const char *filename, const char *otype)
 {
diff --git a/compat/mingw.h b/compat/mingw.h
index 756f3ab..751bb4c 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -178,6 +178,9 @@ int mingw_rmdir(const char *path);
 int mingw_open (const char *filename, int oflags, ...);
 #define open mingw_open
 
+ssize_t mingw_write(int fd, const void *buf, size_t count);
+#define write mingw_write
+
 FILE *mingw_fopen (const char *filename, const char *otype);
 #define fopen mingw_fopen
 
-- 
1.7.0.2.msysgit.0.898.gbf4f.dirty

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

end of thread, other threads:[~2010-10-17 10:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19 12:45 [PATCH] Fix checkout of large files to network shares under Windows XP Sebastian Schuberth
2010-04-19 20:41 ` Junio C Hamano
2010-04-20  9:15   ` Johannes Schindelin
2010-04-19 20:43 ` René Scharfe
2010-04-19 22:46   ` Albert Dvornik
2010-04-20  8:18   ` Johannes Sixt
2010-04-20 12:42   ` Sebastian Schuberth
2010-04-20 12:57     ` Johannes Sixt
2010-04-20 14:21       ` Sebastian Schuberth
2010-04-20 20:49     ` René Scharfe
2010-04-29 20:01       ` René Scharfe
2010-04-30  8:46         ` Johannes Sixt
2010-04-30  9:08         ` Sebastian Schuberth
     [not found]         ` <290b11b5-5dd5-4b83-a6f5-217797ebd5af@t8g2000yqk.googlegroups.com>
2010-10-16 17:23           ` René Scharfe
2010-10-17 10:54             ` Dmitry Potapov

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 NNTP newsgroup(s).