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
7d3fa3af
Commit
7d3fa3af
authored
May 17, 2014
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tell the session why the engine has stopped
parent
adddda17
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
16 deletions
+27
-16
session_base.cpp
src/session_base.cpp
+2
-1
session_base.hpp
src/session_base.hpp
+2
-1
stream_engine.cpp
src/stream_engine.cpp
+16
-13
stream_engine.hpp
src/stream_engine.hpp
+7
-1
No files found.
src/session_base.cpp
View file @
7d3fa3af
...
...
@@ -366,7 +366,8 @@ void zmq::session_base_t::process_attach (i_engine *engine_)
engine
->
plug
(
io_thread
,
this
);
}
void
zmq
::
session_base_t
::
engine_error
()
void
zmq
::
session_base_t
::
engine_error
(
zmq
::
stream_engine_t
::
error_reason_t
reason
)
{
// Engine is dead. Let's forget about it.
engine
=
NULL
;
...
...
src/session_base.hpp
View file @
7d3fa3af
...
...
@@ -27,6 +27,7 @@
#include "io_object.hpp"
#include "pipe.hpp"
#include "socket_base.hpp"
#include "stream_engine.hpp"
namespace
zmq
{
...
...
@@ -55,7 +56,7 @@ namespace zmq
// Following functions are the interface exposed towards the engine.
virtual
void
reset
();
void
flush
();
void
engine_error
();
void
engine_error
(
zmq
::
stream_engine_t
::
error_reason_t
reason
);
// i_pipe_events interface implementation.
void
read_activated
(
zmq
::
pipe_t
*
pipe_
);
...
...
src/stream_engine.cpp
View file @
7d3fa3af
...
...
@@ -274,12 +274,12 @@ void zmq::stream_engine_t::in_event ()
int
const
rc
=
read
(
inpos
,
bufsize
);
if
(
rc
==
0
)
{
error
();
error
(
connection_error
);
return
;
}
if
(
rc
==
-
1
)
{
if
(
errno
!=
EAGAIN
)
error
();
error
(
connection_error
);
return
;
}
...
...
@@ -306,7 +306,7 @@ void zmq::stream_engine_t::in_event ()
// or the session has rejected the message.
if
(
rc
==
-
1
)
{
if
(
errno
!=
EAGAIN
)
{
error
();
error
(
connection_error
);
return
;
}
input_stopped
=
true
;
...
...
@@ -407,7 +407,7 @@ void zmq::stream_engine_t::restart_input ()
if
(
errno
==
EAGAIN
)
session
->
flush
();
else
error
();
error
(
protocol_error
);
return
;
}
...
...
@@ -427,8 +427,11 @@ void zmq::stream_engine_t::restart_input ()
if
(
rc
==
-
1
&&
errno
==
EAGAIN
)
session
->
flush
();
else
if
(
rc
==
-
1
||
io_error
)
error
();
if
(
io_error
)
error
(
connection_error
);
else
if
(
rc
==
-
1
)
error
(
protocol_error
);
else
{
input_stopped
=
false
;
set_pollin
(
handle
);
...
...
@@ -448,12 +451,12 @@ bool zmq::stream_engine_t::handshake ()
const
int
n
=
read
(
greeting_recv
+
greeting_bytes_read
,
greeting_size
-
greeting_bytes_read
);
if
(
n
==
0
)
{
error
();
error
(
connection_error
);
return
false
;
}
if
(
n
==
-
1
)
{
if
(
errno
!=
EAGAIN
)
error
();
error
(
connection_error
);
return
false
;
}
...
...
@@ -631,7 +634,7 @@ bool zmq::stream_engine_t::handshake ()
}
#endif
else
{
error
();
error
(
protocol_error
);
return
false
;
}
next_msg
=
&
stream_engine_t
::
next_handshake_command
;
...
...
@@ -732,7 +735,7 @@ void zmq::stream_engine_t::zap_msg_available ()
const
int
rc
=
mechanism
->
zap_msg_available
();
if
(
rc
==
-
1
)
{
error
();
error
(
protocol_error
);
return
;
}
if
(
input_stopped
)
...
...
@@ -871,7 +874,7 @@ int zmq::stream_engine_t::write_subscription_msg (msg_t *msg_)
return
push_msg_to_session
(
msg_
);
}
void
zmq
::
stream_engine_t
::
error
()
void
zmq
::
stream_engine_t
::
error
(
error_reason_t
reason
)
{
if
(
options
.
raw_sock
)
{
// For raw sockets, send a final 0-length message to the application
...
...
@@ -884,7 +887,7 @@ void zmq::stream_engine_t::error ()
zmq_assert
(
session
);
socket
->
event_disconnected
(
endpoint
,
s
);
session
->
flush
();
session
->
engine_error
();
session
->
engine_error
(
reason
);
unplug
();
delete
this
;
}
...
...
@@ -1006,5 +1009,5 @@ void zmq::stream_engine_t::timer_event (int id_)
has_handshake_timer
=
false
;
// handshake timer expired before handshake completed, so engine fails
error
();
error
(
timeout_error
);
}
src/stream_engine.hpp
View file @
7d3fa3af
...
...
@@ -53,6 +53,12 @@ namespace zmq
{
public
:
enum
error_reason_t
{
protocol_error
,
connection_error
,
timeout_error
};
stream_engine_t
(
fd_t
fd_
,
const
options_t
&
options_
,
const
std
::
string
&
endpoint
);
~
stream_engine_t
();
...
...
@@ -78,7 +84,7 @@ namespace zmq
void
unplug
();
// Function to handle network disconnections.
void
error
();
void
error
(
error_reason_t
reason
);
// Receives the greeting message from the peer.
int
receive_greeting
();
...
...
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