From 9669c70c901474dc21ef08e49478b5f5dead8f64 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Fri, 15 May 2009 03:55:20 -0700 Subject: dict.c: Add dict_allocate_and_serialize - this procedure atomically allocates a buffer and serializes dict into it. - this procedure helps avoid memory corruptions due to race conditions where in new members are added into dict between allocating a buffer for serializing and actually serializing buffer into it. Signed-off-by: Anand V. Avati --- libglusterfs/src/dict.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libglusterfs/src/dict.h') diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h index 23e0f8368f7..e2d87166ae8 100644 --- a/libglusterfs/src/dict.h +++ b/libglusterfs/src/dict.h @@ -76,6 +76,9 @@ 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); +int32_t +dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length); + int32_t dict_iovec_len (dict_t *dict); int32_t dict_to_iovec (dict_t *dict, struct iovec *vec, int32_t count); -- cgit