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
2910a728
Commit
2910a728
authored
Sep 02, 2011
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msg_t::rm_refs closes the message when number of refs drops to 0 (issue 245)
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
82ab08d8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
msg.cpp
src/msg.cpp
+13
-5
msg.hpp
src/msg.hpp
+3
-2
No files found.
src/msg.cpp
View file @
2910a728
...
...
@@ -257,17 +257,25 @@ void zmq::msg_t::add_refs (int refs_)
}
}
void
zmq
::
msg_t
::
rm_refs
(
int
refs_
)
bool
zmq
::
msg_t
::
rm_refs
(
int
refs_
)
{
zmq_assert
(
refs_
>=
0
);
// No copies required.
if
(
!
refs_
)
return
;
return
true
;
// If there's only one reference close the message.
if
(
u
.
base
.
type
!=
type_lmsg
||
!
(
u
.
lmsg
.
flags
&
msg_t
::
shared
))
{
close
();
return
false
;
}
// The only message type that needs special care are long messages.
if
(
u
.
base
.
type
==
type_lmsg
)
{
zmq_assert
(
u
.
lmsg
.
flags
&
msg_t
::
shared
);
u
.
lmsg
.
content
->
refcnt
.
sub
(
refs_
)
;
if
(
!
u
.
lmsg
.
content
->
refcnt
.
sub
(
refs_
)
)
{
close
(
);
return
false
;
}
return
true
;
}
src/msg.hpp
View file @
2910a728
...
...
@@ -73,8 +73,9 @@ namespace zmq
// refs_ times. No need to call copy.
void
add_refs
(
int
refs_
);
// Removes references previously added by add_refs.
void
rm_refs
(
int
refs_
);
// Removes references previously added by add_refs. If the number of
// references drops to 0, the message is closed and false is returned.
bool
rm_refs
(
int
refs_
);
private
:
...
...
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