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
0c4ee0a9
Commit
0c4ee0a9
authored
Jul 29, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1147 from rodgert/master
Update zmq_msg_get(ZMQ_SHARED) to return true for type_cmsg messages
parents
416ee8e7
03f097a5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
zmq_msg_get.txt
doc/zmq_msg_get.txt
+2
-2
zmq.cpp
src/zmq.cpp
+2
-1
test_msg_flags.cpp
tests/test_msg_flags.cpp
+19
-1
No files found.
doc/zmq_msg_get.txt
View file @
0c4ee0a9
...
@@ -30,8 +30,8 @@ aware that the respective socket might be closed already, reused even.
...
@@ -30,8 +30,8 @@ aware that the respective socket might be closed already, reused even.
Currently only implemented for TCP sockets.
Currently only implemented for TCP sockets.
*ZMQ_SHARED*::
*ZMQ_SHARED*::
Indicates that a message
has been copied and MAY share underlying storage
Indicates that a message
MAY share underlying storage with another copy of
with another copy of
this message.
this message.
RETURN VALUE
RETURN VALUE
------------
------------
...
...
src/zmq.cpp
View file @
0c4ee0a9
...
@@ -630,7 +630,8 @@ int zmq_msg_get (zmq_msg_t *msg_, int property_)
...
@@ -630,7 +630,8 @@ int zmq_msg_get (zmq_msg_t *msg_, int property_)
// warning: int64_t to int
// warning: int64_t to int
return
((
zmq
::
msg_t
*
)
msg_
)
->
fd
();
return
((
zmq
::
msg_t
*
)
msg_
)
->
fd
();
case
ZMQ_SHARED
:
case
ZMQ_SHARED
:
return
(((
zmq
::
msg_t
*
)
msg_
)
->
flags
()
&
zmq
::
msg_t
::
shared
)
?
1
:
0
;
return
(((
zmq
::
msg_t
*
)
msg_
)
->
is_cmsg
())
||
(((
zmq
::
msg_t
*
)
msg_
)
->
flags
()
&
zmq
::
msg_t
::
shared
)
?
1
:
0
;
default:
default:
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
...
...
tests/test_msg_flags.cpp
View file @
0c4ee0a9
...
@@ -65,7 +65,7 @@ int main (void)
...
@@ -65,7 +65,7 @@ int main (void)
more
=
zmq_msg_more
(
&
msg
);
more
=
zmq_msg_more
(
&
msg
);
assert
(
more
==
0
);
assert
(
more
==
0
);
// Test ZMQ_SHARED property
// Test ZMQ_SHARED property
(case 1, refcounted messages)
zmq_msg_t
msg_a
;
zmq_msg_t
msg_a
;
rc
=
zmq_msg_init_size
(
&
msg_a
,
1024
);
// large enough to be a type_lmsg
rc
=
zmq_msg_init_size
(
&
msg_a
,
1024
);
// large enough to be a type_lmsg
assert
(
rc
==
0
);
assert
(
rc
==
0
);
...
@@ -85,6 +85,24 @@ int main (void)
...
@@ -85,6 +85,24 @@ int main (void)
rc
=
zmq_msg_get
(
&
msg_b
,
ZMQ_SHARED
);
rc
=
zmq_msg_get
(
&
msg_b
,
ZMQ_SHARED
);
assert
(
rc
==
1
);
assert
(
rc
==
1
);
// cleanup
rc
=
zmq_msg_close
(
&
msg_a
);
assert
(
rc
==
0
);
rc
=
zmq_msg_close
(
&
msg_b
);
assert
(
rc
==
0
);
// Test ZMQ_SHARED property (case 2, constant data messages)
rc
=
zmq_msg_init_data
(
&
msg_a
,
(
void
*
)
"TEST"
,
5
,
0
,
0
);
assert
(
rc
==
0
);
// Message reports as shared
rc
=
zmq_msg_get
(
&
msg_a
,
ZMQ_SHARED
);
assert
(
rc
==
1
);
// cleanup
rc
=
zmq_msg_close
(
&
msg_a
);
assert
(
rc
==
0
);
// Deallocate the infrastructure.
// Deallocate the infrastructure.
rc
=
zmq_close
(
sc
);
rc
=
zmq_close
(
sc
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
...
...
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