summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.hpp4
-rw-r--r--src/msg.cpp6
-rw-r--r--src/msg.hpp13
3 files changed, 16 insertions, 7 deletions
diff --git a/src/config.hpp b/src/config.hpp
index 3984fcf..96e39de 100644
--- a/src/config.hpp
+++ b/src/config.hpp
@@ -39,10 +39,6 @@ namespace zmq
// Commands in pipe per allocation event.
command_pipe_granularity = 16,
- // Size in bytes of the largest message that is still copied around
- // rather than being reference-counted.
- max_vsm_size = 29,
-
// Determines how often does socket poll for new commands when it
// still has unprocessed messages to handle. Thus, if it is set to 100,
// socket will process 100 inbound messages before doing the poll.
diff --git a/src/msg.cpp b/src/msg.cpp
index 84ca3e2..fcc04ab 100644
--- a/src/msg.cpp
+++ b/src/msg.cpp
@@ -19,6 +19,7 @@
*/
#include "msg.hpp"
+#include "../include/zmq.h"
#include <string.h>
#include <errno.h>
@@ -29,6 +30,11 @@
#include "likely.hpp"
#include "err.hpp"
+// Check whether the sizes of public representation of the message (zmq_msg_t)
+// and private represenation of the message (zmq::msg_t) match.
+typedef char zmq_msg_size_check
+ [2 * ((sizeof (zmq::msg_t) == sizeof (zmq_msg_t)) != 0) - 1];
+
bool zmq::msg_t::check ()
{
return u.base.type >= type_min && u.base.type <= type_max;
diff --git a/src/msg.hpp b/src/msg.hpp
index 602ae55..2111bf1 100644
--- a/src/msg.hpp
+++ b/src/msg.hpp
@@ -77,6 +77,10 @@ namespace zmq
private:
+ // Size in bytes of the largest message that is still copied around
+ // rather than being reference-counted.
+ enum {max_vsm_size = 29};
+
// Shared message buffer. Message data are either allocated in one
// continuous block along with this structure - thus avoiding one
// malloc/free pair or they are stored in used-supplied memory.
@@ -109,21 +113,24 @@ namespace zmq
// the union.
union {
struct {
+ unsigned char unused [max_vsm_size + 1];
unsigned char type;
unsigned char flags;
} base;
struct {
+ unsigned char data [max_vsm_size];
+ unsigned char size;
unsigned char type;
unsigned char flags;
- unsigned char size;
- unsigned char data [max_vsm_size];
} vsm;
struct {
+ content_t *content;
+ unsigned char unused [max_vsm_size + 1 - sizeof (content_t*)];
unsigned char type;
unsigned char flags;
- content_t *content;
} lmsg;
struct {
+ unsigned char unused [max_vsm_size + 1];
unsigned char type;
unsigned char flags;
} delimiter;