summaryrefslogtreecommitdiff
path: root/src/posix.h
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2014-02-15 23:09:01 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2014-02-16 16:56:37 +0000
commit0197d4107a2996dc2ed4e98698e281c2d5fa44e1 (patch)
tree5be111f1c313d8a83ca6297354fb27c4cc768c6c /src/posix.h
parentdbd2ca356b8a16d028e45c5263e9c460be13d338 (diff)
downloadlibgit2-0197d4107a2996dc2ed4e98698e281c2d5fa44e1.tar.gz
Check for EWOULDBLOCK as well as EAGAIN on write.
On some systems, notably HP PA-RISC systems running Linux or HP-UX, EWOULDBLOCK and EAGAIN are not the same value. POSIX (and these OSes) allow EWOULDBLOCK to occur on write(2) (and send(2), etc.), so check explicitly for this case as well as EAGAIN by defining and using a macro GIT_ISBLOCKED that considers both. The macro is necessary because MSYS does not provide EWOULDBLOCK and compilation fails if an attempt is made to use it unconditionally. On most systems, where the two values are the same, the compiler will simply optimize this check out and it will have no effect.
Diffstat (limited to 'src/posix.h')
-rw-r--r--src/posix.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/posix.h b/src/posix.h
index 6d3a84eba..f85b1aebd 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;
/**