summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/glfs-internal.h')
-rw-r--r--api/src/glfs-internal.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index ec1d5579df7..f04557323a0 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -18,6 +18,26 @@
#define DEFAULT_REVAL_COUNT 1
+/*
+ * syncop_xxx() calls are executed in two ways, one is inside a synctask where
+ * the executing function will do 'swapcontext' and the other is without
+ * synctask where the executing thread is made to wait using pthread_cond_wait.
+ * Executing thread may change when syncop_xxx() is executed inside a synctask.
+ * This leads to errno_location change i.e. errno may give errno of
+ * non-executing thread. So errno is not touched inside a synctask execution.
+ * All gfapi calls are executed using the second way of executing syncop_xxx()
+ * where the executing thread waits using pthread_cond_wait so it is ok to set
+ * errno in these cases. The following macro makes syncop_xxx() behave just
+ * like a system call, where -1 is returned and errno is set when a failure
+ * occurs.
+ */
+#define DECODE_SYNCOP_ERR(ret) do { \
+ if (ret < 0) { \
+ errno = -ret; \
+ ret = -1; \
+ } \
+ } while (0)
+
#define ESTALE_RETRY(ret,errno,reval,loc,label) do { \
if (ret == -1 && errno == ESTALE) { \
if (reval < DEFAULT_REVAL_COUNT) { \