aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-19 01:49:53 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-19 01:49:58 +0200
commit198e8ee15037d1de39a3d23d3bf579fed0561ba3 (patch)
tree05739bf7d251f1af6c1c9110cb98201c10bf7848
parentDo not just queue "Client close" message, but also send it (diff)
downloadmds-198e8ee15037d1de39a3d23d3bf579fed0561ba3.tar.gz
mds-198e8ee15037d1de39a3d23d3bf579fed0561ba3.tar.bz2
mds-198e8ee15037d1de39a3d23d3bf579fed0561ba3.tar.xz
store structure version for all structures when marshalling
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-server/client.c6
-rw-r--r--src/mds-server/client.h2
-rw-r--r--src/mds-server/interception_condition.c10
-rw-r--r--src/mds-server/interception_condition.h2
-rw-r--r--src/mds-server/multicast.c9
-rw-r--r--src/mds-server/multicast.h2
-rw-r--r--src/mds-server/queued_interception.c5
-rw-r--r--src/mds-server/queued_interception.h2
8 files changed, 30 insertions, 8 deletions
diff --git a/src/mds-server/client.c b/src/mds-server/client.c
index 76c7250..23511b4 100644
--- a/src/mds-server/client.c
+++ b/src/mds-server/client.c
@@ -141,7 +141,7 @@ void client_destroy(client_t* restrict this)
*/
size_t client_marshal_size(const client_t* restrict this)
{
- size_t n = sizeof(ssize_t) + 2 * sizeof(int) + sizeof(uint64_t) + 5 * sizeof(size_t);
+ size_t n = sizeof(ssize_t) + 3 * sizeof(int) + sizeof(uint64_t) + 5 * sizeof(size_t);
size_t i;
n += mds_message_marshal_size(&(this->message));
@@ -166,6 +166,7 @@ size_t client_marshal_size(const client_t* restrict this)
size_t client_marshal(const client_t* restrict this, char* restrict data)
{
size_t i, n;
+ buf_set_next(data, int, CLIENT_T_VERSION);
buf_set_next(data, ssize_t, this->list_entry);
buf_set_next(data, int, this->socket_fd);
buf_set_next(data, int, this->open);
@@ -207,6 +208,8 @@ size_t client_unmarshal(client_t* restrict this, char* restrict data)
this->modify_mutex_created = 0;
this->modify_cond_created = 0;
this->multicasts_count = 0;
+ /* buf_get_next(data, int, CLIENT_T_VERSION); */
+ buf_next(data, int, 1);
buf_get_next(data, ssize_t, this->list_entry);
buf_get_next(data, int, this->socket_fd);
buf_get_next(data, int, this->open);
@@ -281,6 +284,7 @@ size_t client_unmarshal(client_t* restrict this, char* restrict data)
size_t client_unmarshal_skip(char* restrict data)
{
size_t n, c, rc = sizeof(ssize_t) + 2 * sizeof(int) + sizeof(uint64_t) + 5 * sizeof(size_t);
+ buf_next(data, int, 1);
buf_next(data, ssize_t, 1);
buf_next(data, int, 2);
buf_next(data, uint64_t, 1);
diff --git a/src/mds-server/client.h b/src/mds-server/client.h
index 39ed791..ab8046a 100644
--- a/src/mds-server/client.h
+++ b/src/mds-server/client.h
@@ -30,6 +30,8 @@
+#define CLIENT_T_VERSION 0
+
/**
* Client information structure
*/
diff --git a/src/mds-server/interception_condition.c b/src/mds-server/interception_condition.c
index 47a082a..8f11adb 100644
--- a/src/mds-server/interception_condition.c
+++ b/src/mds-server/interception_condition.c
@@ -32,7 +32,7 @@
*/
size_t interception_condition_marshal_size(const interception_condition_t* restrict this)
{
- return sizeof(size_t) + sizeof(int64_t) + sizeof(int) + (strlen(this->condition) + 1) * sizeof(char);
+ return sizeof(size_t) + sizeof(int64_t) + 2 * sizeof(int) + (strlen(this->condition) + 1) * sizeof(char);
}
/**
@@ -44,12 +44,13 @@ size_t interception_condition_marshal_size(const interception_condition_t* restr
*/
size_t interception_condition_marshal(const interception_condition_t* restrict this, char* restrict data)
{
- size_t n = (strlen(this->condition) + 1) * sizeof(char);;
+ size_t n = (strlen(this->condition) + 1) * sizeof(char);
+ buf_set_next(data, int, INTERCEPTION_CONDITION_T_VERSION);
buf_set_next(data, size_t, this->header_hash);
buf_set_next(data, int64_t, this->priority);
buf_set_next(data, int, this->modifying);
memcpy(data, this->condition, n);
- return sizeof(size_t) + sizeof(int64_t) + sizeof(int) + n;
+ return sizeof(size_t) + sizeof(int64_t) + 2 * sizeof(int) + n;
}
@@ -64,6 +65,8 @@ size_t interception_condition_unmarshal(interception_condition_t* restrict this,
{
size_t n;
this->condition = NULL;
+ /* buf_get_next(data, int, INTERCEPTION_CONDITION_T_VERSION); */
+ buf_next(data, int, 1);
buf_get_next(data, size_t, this->header_hash);
buf_get_next(data, int64_t, this->priority);
buf_get_next(data, int, this->modifying);
@@ -84,6 +87,7 @@ size_t interception_condition_unmarshal(interception_condition_t* restrict this,
size_t interception_condition_unmarshal_skip(char* restrict data)
{
size_t n = sizeof(size_t) + sizeof(int64_t) + sizeof(int);
+ buf_next(data, int, 1);
buf_next(data, size_t, 1);
buf_next(data, int64_t, 1);
buf_next(data, int, 1);
diff --git a/src/mds-server/interception_condition.h b/src/mds-server/interception_condition.h
index 63b9f1c..19f2c68 100644
--- a/src/mds-server/interception_condition.h
+++ b/src/mds-server/interception_condition.h
@@ -23,6 +23,8 @@
#include <stdint.h>
+#define INTERCEPTION_CONDITION_T_VERSION 0
+
/**
* A condition for a message being intercepted by a client
*/
diff --git a/src/mds-server/multicast.c b/src/mds-server/multicast.c
index 9be0e8d..21c9e60 100644
--- a/src/mds-server/multicast.c
+++ b/src/mds-server/multicast.c
@@ -62,7 +62,7 @@ void multicast_destroy(multicast_t* restrict this)
*/
size_t multicast_marshal_size(const multicast_t* restrict this)
{
- size_t rc = 5 * sizeof(size_t) + this->message_length * sizeof(char);
+ size_t rc = sizeof(int) + 5 * sizeof(size_t) + this->message_length * sizeof(char);
size_t i;
for (i = 0; i < this->interceptions_count; i++)
rc += queued_interception_marshal_size();
@@ -79,8 +79,9 @@ size_t multicast_marshal_size(const multicast_t* restrict this)
*/
size_t multicast_marshal(const multicast_t* restrict this, char* restrict data)
{
- size_t rc = 5 * sizeof(size_t);
+ size_t rc = sizeof(int) + 5 * sizeof(size_t);
size_t i, n;
+ buf_set_next(data, int, MULTICAST_T_VERSION);
buf_set_next(data, size_t, this->interceptions_count);
buf_set_next(data, size_t, this->interceptions_ptr);
buf_set_next(data, size_t, this->message_length);
@@ -112,6 +113,8 @@ size_t multicast_unmarshal(multicast_t* restrict this, char* restrict data)
size_t i, n;
this->interceptions = NULL;
this->message = NULL;
+ /* buf_get_next(data, int, MULTICAST_T_VERSION); */
+ buf_next(data, int, 1);
buf_get_next(data, size_t, this->interceptions_count);
buf_get_next(data, size_t, this->interceptions_ptr);
buf_get_next(data, size_t, this->message_length);
@@ -143,7 +146,7 @@ size_t multicast_unmarshal_skip(char* restrict data)
{
size_t interceptions_count = buf_cast(data, size_t, 0);
size_t message_length = buf_cast(data, size_t, 2);
- size_t rc = 5 * sizeof(size_t) + message_length * sizeof(char);
+ size_t rc = sizeof(int) + 5 * sizeof(size_t) + message_length * sizeof(char);
size_t n;
while (interceptions_count--)
{
diff --git a/src/mds-server/multicast.h b/src/mds-server/multicast.h
index 3ea1e07..d23d7ce 100644
--- a/src/mds-server/multicast.h
+++ b/src/mds-server/multicast.h
@@ -22,6 +22,8 @@
#include "queued_interception.h"
+#define MULTICAST_T_VERSION 0
+
/**
* Message multicast state
*/
diff --git a/src/mds-server/queued_interception.c b/src/mds-server/queued_interception.c
index 56d58c3..d162558 100644
--- a/src/mds-server/queued_interception.c
+++ b/src/mds-server/queued_interception.c
@@ -28,7 +28,7 @@
*/
size_t queued_interception_marshal_size(void)
{
- return sizeof(int64_t) + 2 * sizeof(int);
+ return sizeof(int64_t) + 3 * sizeof(int);
}
@@ -41,6 +41,7 @@ size_t queued_interception_marshal_size(void)
*/
size_t queued_interception_marshal(const queued_interception_t* restrict this, char* restrict data)
{
+ buf_set_next(data, int, QUEUED_INTERCEPTION_T_VERSION);
buf_set_next(data, int64_t, this->priority);
buf_set_next(data, int, this->modifying);
buf_set_next(data, int, this->client->socket_fd);
@@ -58,6 +59,8 @@ size_t queued_interception_marshal(const queued_interception_t* restrict this, c
size_t queued_interception_unmarshal(queued_interception_t* restrict this, char* restrict data)
{
this->client = NULL;
+ /* buf_get_next(data, int, QUEUED_INTERCEPTION_T_VERSION); */
+ buf_next(data, int, 1);
buf_get_next(data, int64_t, this->priority);
buf_get_next(data, int, this->modifying);
buf_get_next(data, int, this->socket_fd);
diff --git a/src/mds-server/queued_interception.h b/src/mds-server/queued_interception.h
index ddab418..3c7fe51 100644
--- a/src/mds-server/queued_interception.h
+++ b/src/mds-server/queued_interception.h
@@ -24,6 +24,8 @@
#include <stdint.h>
+#define QUEUED_INTERCEPTION_T_VERSION 0
+
/**
* A queued interception
*/