Commit e0ebaaa53ea1154a1f392dae463453ac6c428d78

Vicent Marti 2014-02-18T18:48:43

Merge pull request #2121 from bk2204/ewouldblock Check for EWOULDBLOCK as well as EAGAIN on write.

diff --git a/src/posix.c b/src/posix.c
index 525785f..7b2962f 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -189,7 +189,7 @@ int p_write(git_file fd, const void *buf, size_t cnt)
 		r = write(fd, b, cnt);
 #endif
 		if (r < 0) {
-			if (errno == EINTR || errno == EAGAIN)
+			if (errno == EINTR || GIT_ISBLOCKED(errno))
 				continue;
 			return -1;
 		}
diff --git a/src/posix.h b/src/posix.h
index 6d3a84e..f85b1ae 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -29,6 +29,15 @@
 #define O_CLOEXEC 0
 #endif
 
+/* Determine whether an errno value indicates that a read or write failed
+ * because the descriptor is blocked.
+ */
+#if defined(EWOULDBLOCK)
+#define GIT_ISBLOCKED(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
+#else
+#define GIT_ISBLOCKED(e) ((e) == EAGAIN)
+#endif
+
 typedef int git_file;
 
 /**