diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-11 19:14:57 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-11 19:14:57 +0200 |
commit | d8b997547139babdddadb2e401bb6d3e75ff9227 (patch) | |
tree | b9ef4ead80e1410bb1d5fcc7b78360133a6e8ee9 /src/mds-server/client.c | |
parent | derp (diff) | |
download | mds-d8b997547139babdddadb2e401bb6d3e75ff9227.tar.gz mds-d8b997547139babdddadb2e401bb6d3e75ff9227.tar.bz2 mds-d8b997547139babdddadb2e401bb6d3e75ff9227.tar.xz |
handle interceptions, everything except receiving modifications
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-server/client.c')
-rw-r--r-- | src/mds-server/client.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mds-server/client.c b/src/mds-server/client.c index 0a8b107..6c46c90 100644 --- a/src/mds-server/client.c +++ b/src/mds-server/client.c @@ -52,6 +52,11 @@ void client_destroy(client_t* restrict this) free(this->multicasts); } free(this->send_pending); + if (this->modify_message != NULL) + { + mds_message_destroy(this->modify_message); + free(this->modify_message); + } free(this); } @@ -64,7 +69,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) + 4 * sizeof(size_t); + size_t n = sizeof(ssize_t) + 2 * sizeof(int) + sizeof(uint64_t) + 5 * sizeof(size_t); size_t i; n += mds_message_marshal_size(&(this->message), 1); @@ -73,6 +78,7 @@ size_t client_marshal_size(const client_t* restrict this) for (i = 0; i < this->multicasts_count; i++) n += multicast_marshal_size(this->multicasts + i); n += this->send_pending_size * sizeof(char); + n += this->modify_message == NULL ? 0 : mds_message_marshal_size(this->modify_message, 1); return n; } @@ -105,6 +111,9 @@ size_t client_marshal(const client_t* restrict this, char* restrict data) buf_set_next(data, size_t, this->send_pending_size); if (this->send_pending_size > 0) memcpy(data, this->send_pending, this->send_pending_size * sizeof(char)); + data += this->send_pending_size; + if (this->modify_message != NULL) + mds_message_marshal(this->modify_message, data, 1); return client_marshal_size(this); } @@ -163,7 +172,13 @@ size_t client_unmarshal(client_t* restrict this, char* restrict data) if (xmalloc(this->send_pending, this->send_pending_size, char)) goto fail; memcpy(this->send_pending, data, this->send_pending_size * sizeof(char)); + data += this->send_pending_size; } + buf_get_next(data, size_t, n); + if (n > 0) + mds_message_unmarshal(this->modify_message, data); + else + this->modify_message = NULL; return rc; fail: @@ -175,6 +190,11 @@ size_t client_unmarshal(client_t* restrict this, char* restrict data) multicast_destroy(this->multicasts + i); free(this->multicasts); free(this->send_pending); + if (this->modify_message != NULL) + { + mds_message_destroy(this->modify_message); + free(this->modify_message); + } return 0; } @@ -186,7 +206,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) + 3 * sizeof(size_t); + size_t n, c, rc = sizeof(ssize_t) + 2 * sizeof(int) + sizeof(uint64_t) + 5 * sizeof(size_t); buf_next(data, ssize_t, 1); buf_next(data, int, 2); buf_next(data, uint64_t, 1); @@ -209,6 +229,8 @@ size_t client_unmarshal_skip(char* restrict data) } buf_get_next(data, size_t, n); rc += n * sizeof(char); + buf_get_next(data, size_t, n); + rc += n * sizeof(char); return rc; } |