Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
724b2bb8
Commit
724b2bb8
authored
Apr 29, 2014
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pointer to properties into message structure
parent
26bf7497
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
zmq.h
include/zmq.h
+1
-1
msg.cpp
src/msg.cpp
+8
-3
msg.hpp
src/msg.hpp
+15
-7
No files found.
include/zmq.h
View file @
724b2bb8
...
@@ -200,7 +200,7 @@ ZMQ_EXPORT int zmq_ctx_destroy (void *context);
...
@@ -200,7 +200,7 @@ ZMQ_EXPORT int zmq_ctx_destroy (void *context);
/* 0MQ message definition. */
/* 0MQ message definition. */
/******************************************************************************/
/******************************************************************************/
typedef
struct
zmq_msg_t
{
unsigned
char
_
[
4
0
];}
zmq_msg_t
;
typedef
struct
zmq_msg_t
{
unsigned
char
_
[
4
8
];}
zmq_msg_t
;
typedef
void
(
zmq_free_fn
)
(
void
*
data
,
void
*
hint
);
typedef
void
(
zmq_free_fn
)
(
void
*
data
,
void
*
hint
);
...
...
src/msg.cpp
View file @
724b2bb8
...
@@ -41,6 +41,7 @@ bool zmq::msg_t::check ()
...
@@ -41,6 +41,7 @@ bool zmq::msg_t::check ()
int
zmq
::
msg_t
::
init
()
int
zmq
::
msg_t
::
init
()
{
{
u
.
vsm
.
properties
=
NULL
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
size
=
0
;
u
.
vsm
.
size
=
0
;
...
@@ -52,11 +53,13 @@ int zmq::msg_t::init_size (size_t size_)
...
@@ -52,11 +53,13 @@ int zmq::msg_t::init_size (size_t size_)
{
{
file_desc
=
-
1
;
file_desc
=
-
1
;
if
(
size_
<=
max_vsm_size
)
{
if
(
size_
<=
max_vsm_size
)
{
u
.
vsm
.
properties
=
NULL
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
size
=
(
unsigned
char
)
size_
;
u
.
vsm
.
size
=
(
unsigned
char
)
size_
;
}
}
else
{
else
{
u
.
lmsg
.
properties
=
NULL
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
content
=
u
.
lmsg
.
content
=
...
@@ -81,17 +84,19 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
...
@@ -81,17 +84,19 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
// If data is NULL and size is not 0, a segfault
// If data is NULL and size is not 0, a segfault
// would occur once the data is accessed
// would occur once the data is accessed
zmq_assert
(
data_
!=
NULL
||
size_
==
0
);
zmq_assert
(
data_
!=
NULL
||
size_
==
0
);
file_desc
=
-
1
;
file_desc
=
-
1
;
// Initialize constant message if there's no need to deallocate
// Initialize constant message if there's no need to deallocate
if
(
ffn_
==
NULL
)
{
if
(
ffn_
==
NULL
)
{
u
.
cmsg
.
properties
=
NULL
;
u
.
cmsg
.
type
=
type_cmsg
;
u
.
cmsg
.
type
=
type_cmsg
;
u
.
cmsg
.
flags
=
0
;
u
.
cmsg
.
flags
=
0
;
u
.
cmsg
.
data
=
data_
;
u
.
cmsg
.
data
=
data_
;
u
.
cmsg
.
size
=
size_
;
u
.
cmsg
.
size
=
size_
;
}
}
else
{
else
{
u
.
lmsg
.
properties
=
NULL
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
content
=
(
content_t
*
)
malloc
(
sizeof
(
content_t
));
u
.
lmsg
.
content
=
(
content_t
*
)
malloc
(
sizeof
(
content_t
));
...
@@ -112,6 +117,7 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
...
@@ -112,6 +117,7 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
int
zmq
::
msg_t
::
init_delimiter
()
int
zmq
::
msg_t
::
init_delimiter
()
{
{
u
.
delimiter
.
properties
=
NULL
;
u
.
delimiter
.
type
=
type_delimiter
;
u
.
delimiter
.
type
=
type_delimiter
;
u
.
delimiter
.
flags
=
0
;
u
.
delimiter
.
flags
=
0
;
return
0
;
return
0
;
...
@@ -336,4 +342,3 @@ bool zmq::msg_t::rm_refs (int refs_)
...
@@ -336,4 +342,3 @@ bool zmq::msg_t::rm_refs (int refs_)
return
true
;
return
true
;
}
}
src/msg.hpp
View file @
724b2bb8
...
@@ -86,9 +86,12 @@ namespace zmq
...
@@ -86,9 +86,12 @@ namespace zmq
private
:
private
:
class
i_properties
;
// Size in bytes of the largest message that is still copied around
// Size in bytes of the largest message that is still copied around
// rather than being reference-counted.
// rather than being reference-counted.
enum
{
max_vsm_size
=
29
};
enum
{
msg_t_size
=
48
};
enum
{
max_vsm_size
=
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
3
)
};
// Shared message buffer. Message data are either allocated in one
// Shared message buffer. Message data are either allocated in one
// continuous block along with this structure - thus avoiding one
// continuous block along with this structure - thus avoiding one
...
@@ -120,42 +123,47 @@ namespace zmq
...
@@ -120,42 +123,47 @@ namespace zmq
type_cmsg
=
104
,
type_cmsg
=
104
,
type_max
=
104
type_max
=
104
};
};
// the file descriptor where this message originated, needs to be 64bit due to alignment
// the file descriptor where this message originated, needs to be 64bit due to alignment
int64_t
file_desc
;
int64_t
file_desc
;
// Note that fields shared between different message types are not
// Note that fields shared between different message types are not
// moved to tha parent class (msg_t). This way we ge
r
tighter packing
// moved to tha parent class (msg_t). This way we ge
t
tighter packing
// of the data. Shared fields can be accessed via 'base' member of
// of the data. Shared fields can be accessed via 'base' member of
// the union.
// the union.
union
{
union
{
struct
{
struct
{
unsigned
char
unused
[
max_vsm_size
+
1
];
i_properties
*
properties
;
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
base
;
}
base
;
struct
{
struct
{
i_properties
*
properties
;
unsigned
char
data
[
max_vsm_size
];
unsigned
char
data
[
max_vsm_size
];
unsigned
char
size
;
unsigned
char
size
;
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
vsm
;
}
vsm
;
struct
{
struct
{
i_properties
*
properties
;
content_t
*
content
;
content_t
*
content
;
unsigned
char
unused
[
m
ax_vsm_size
+
1
-
sizeof
(
content_t
*
)];
unsigned
char
unused
[
m
sg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
sizeof
(
content_t
*
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
lmsg
;
}
lmsg
;
struct
{
struct
{
i_properties
*
properties
;
void
*
data
;
void
*
data
;
size_t
size
;
size_t
size
;
unsigned
char
unused
unsigned
char
unused
[
m
ax_vsm_size
+
1
-
sizeof
(
void
*
)
-
sizeof
(
size_t
)];
[
m
sg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
sizeof
(
void
*
)
+
sizeof
(
size_t
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
cmsg
;
}
cmsg
;
struct
{
struct
{
unsigned
char
unused
[
max_vsm_size
+
1
];
i_properties
*
properties
;
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
delimiter
;
}
delimiter
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment