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
f0316771
Commit
f0316771
authored
Mar 20, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rollback of half-processed messages in case of disconnection
parent
dfdaff5e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
session.cpp
src/session.cpp
+26
-1
session.hpp
src/session.hpp
+4
-0
No files found.
src/session.cpp
View file @
f0316771
...
...
@@ -28,6 +28,7 @@ zmq::session_t::session_t (object_t *parent_, socket_base_t *owner_,
const
options_t
&
options_
)
:
owned_t
(
parent_
,
owner_
),
in_pipe
(
NULL
),
incomplete_in
(
false
),
active
(
true
),
out_pipe
(
NULL
),
engine
(
NULL
),
...
...
@@ -72,7 +73,11 @@ bool zmq::session_t::read (::zmq_msg_t *msg_)
if
(
!
in_pipe
||
!
active
)
return
false
;
return
in_pipe
->
read
(
msg_
);
if
(
!
in_pipe
->
read
(
msg_
))
return
false
;
incomplete_in
=
msg_
->
flags
&
ZMQ_MSG_TBC
;
return
true
;
}
bool
zmq
::
session_t
::
write
(
::
zmq_msg_t
*
msg_
)
...
...
@@ -102,6 +107,26 @@ void zmq::session_t::detach (owned_t *reconnecter_)
// Engine is terminating itself. No need to deallocate it from here.
engine
=
NULL
;
// Get rid of half-processed messages in the out pipe. Flush any
// unflushed messages upstream.
if
(
out_pipe
)
{
out_pipe
->
rollback
();
out_pipe
->
flush
();
}
// Remove any half-read message from the in pipe.
if
(
in_pipe
)
{
while
(
incomplete_in
)
{
zmq_msg_t
msg
;
zmq_msg_init
(
&
msg
);
if
(
!
read
(
&
msg
))
{
zmq_assert
(
!
incomplete_in
);
break
;
}
zmq_msg_close
(
&
msg
);
}
}
// Terminate transient session.
if
(
!
ordinal
&&
(
peer_identity
.
empty
()
||
peer_identity
[
0
]
==
0
))
term
();
...
...
src/session.hpp
View file @
f0316771
...
...
@@ -72,6 +72,10 @@ namespace zmq
// Inbound pipe, i.e. one the session is getting messages from.
class
reader_t
*
in_pipe
;
// This flag is true if the remainder of the message being processed
// is still in the in pipe.
bool
incomplete_in
;
// If true, in_pipe is active. Otherwise there are no messages to get.
bool
active
;
...
...
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