summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/dict.c20
-rw-r--r--libglusterfs/src/dict.h2
-rw-r--r--libglusterfs/src/syncop.h23
3 files changed, 45 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 6f7adb51589..96cb9e94bda 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -473,6 +473,26 @@ dict_get (dict_t *this, char *key)
return NULL;
}
+int
+dict_key_count (dict_t *this)
+{
+ int ret = -1;
+
+ if (!this) {
+ gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "dict passed is NULL");
+ return ret;
+ }
+
+ LOCK (&this->lock);
+ {
+ ret = this->count;
+ }
+ UNLOCK (&this->lock);
+
+ return ret;
+}
+
void
dict_del (dict_t *this, char *key)
{
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index 04f0ed9b164..a7fb6c78425 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -107,6 +107,8 @@ data_t *dict_get (dict_t *this, char *key);
void dict_del (dict_t *this, char *key);
int dict_reset (dict_t *dict);
+int dict_key_count (dict_t *this);
+
int32_t dict_serialized_length (dict_t *dict);
int32_t dict_serialize (dict_t *dict, char *buf);
int32_t dict_unserialize (char *buf, int32_t size, dict_t **fill);
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index c2387e62cd2..0d0da58f4cf 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -258,6 +258,29 @@ struct syncopctx {
} while (0)
+/*
+ * 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; \
+ } else { \
+ errno = 0; \
+ } \
+ } while (0)
+
+
#define SYNCENV_DEFAULT_STACKSIZE (2 * 1024 * 1024)
struct syncenv * syncenv_new (size_t stacksize, int procmin, int procmax);