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
810d3b43
Unverified
Commit
810d3b43
authored
Oct 04, 2019
by
Luca Boccassi
Committed by
GitHub
Oct 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3703 from somdoron/ws_mechanism
problem: wss transport return incorrect return code for error
parents
8d9acb72
a9bb5264
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
8 deletions
+53
-8
stream_engine_base.cpp
src/stream_engine_base.cpp
+3
-3
stream_engine_base.hpp
src/stream_engine_base.hpp
+1
-0
wss_engine.cpp
src/wss_engine.cpp
+47
-5
wss_engine.hpp
src/wss_engine.hpp
+2
-0
No files found.
src/stream_engine_base.cpp
View file @
810d3b43
...
...
@@ -354,7 +354,7 @@ void zmq::stream_engine_base_t::out_event ()
// If there is no data to send, stop polling for output.
if
(
_outsize
==
0
)
{
_output_stopped
=
true
;
reset_pollout
(
_handle
);
reset_pollout
();
return
;
}
}
...
...
@@ -370,7 +370,7 @@ void zmq::stream_engine_base_t::out_event ()
// The engine is not terminated until we detect input error;
// this is necessary to prevent losing incoming messages.
if
(
nbytes
==
-
1
)
{
reset_pollout
(
_handle
);
reset_pollout
();
return
;
}
...
...
@@ -381,7 +381,7 @@ void zmq::stream_engine_base_t::out_event ()
// to send, stop polling for output.
if
(
unlikely
(
_handshaking
))
if
(
_outsize
==
0
)
reset_pollout
(
_handle
);
reset_pollout
();
}
void
zmq
::
stream_engine_base_t
::
restart_output
()
...
...
src/stream_engine_base.hpp
View file @
810d3b43
...
...
@@ -102,6 +102,7 @@ class stream_engine_base_t : public io_object_t, public i_engine
virtual
int
read
(
void
*
data
,
size_t
size_
);
virtual
int
write
(
const
void
*
data_
,
size_t
size_
);
void
reset_pollout
()
{
io_object_t
::
reset_pollout
(
_handle
);
}
void
set_pollout
()
{
io_object_t
::
set_pollout
(
_handle
);
}
void
set_pollin
()
{
io_object_t
::
set_pollin
(
_handle
);
}
session_base_t
*
session
()
{
return
_session
;
}
...
...
src/wss_engine.cpp
View file @
810d3b43
...
...
@@ -128,21 +128,53 @@ void zmq::wss_engine_t::plug_internal ()
in_event
();
}
void
zmq
::
wss_engine_t
::
out_event
()
{
if
(
_established
)
return
ws_engine_t
::
out_event
();
int
rc
=
gnutls_handshake
(
_tls_session
);
reset_pollout
();
if
(
rc
==
GNUTLS_E_SUCCESS
)
{
start_ws_handshake
();
_established
=
true
;
return
;
}
else
if
(
rc
==
GNUTLS_E_AGAIN
)
{
int
direction
=
gnutls_record_get_direction
(
_tls_session
);
if
(
direction
==
1
)
set_pollout
();
return
;
}
else
if
(
rc
==
GNUTLS_E_INTERRUPTED
||
rc
==
GNUTLS_E_WARNING_ALERT_RECEIVED
)
{
return
;
}
else
{
error
(
zmq
::
i_engine
::
connection_error
);
return
;
}
}
bool
zmq
::
wss_engine_t
::
handshake
()
{
if
(
!
_established
)
{
int
rc
=
gnutls_handshake
(
_tls_session
);
// TODO: when E_AGAIN is returned we might need to call gnutls_handshake for out_event as well, see gnutls_record_get_direction
if
(
rc
==
GNUTLS_E_SUCCESS
)
{
start_ws_handshake
();
_established
=
true
;
return
false
;
}
else
if
(
rc
==
GNUTLS_E_AGAIN
||
rc
==
GNUTLS_E_INTERRUPTED
||
rc
==
GNUTLS_E_WARNING_ALERT_RECEIVED
)
}
else
if
(
rc
==
GNUTLS_E_AGAIN
)
{
int
direction
=
gnutls_record_get_direction
(
_tls_session
);
if
(
direction
==
1
)
set_pollout
();
return
false
;
}
else
if
(
rc
==
GNUTLS_E_INTERRUPTED
||
rc
==
GNUTLS_E_WARNING_ALERT_RECEIVED
)
{
return
false
;
else
{
}
else
{
error
(
zmq
::
i_engine
::
connection_error
);
return
false
;
}
...
...
@@ -171,6 +203,11 @@ int zmq::wss_engine_t::read (void *data_, size_t size_)
return
-
1
;
}
if
(
rc
<
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
// TODO: change return type to ssize_t (signed)
return
rc
;
}
...
...
@@ -189,6 +226,11 @@ int zmq::wss_engine_t::write (const void *data_, size_t size_)
return
-
1
;
}
if
(
rc
<
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
// TODO: change return type to ssize_t (signed)
return
rc
;
}
src/wss_engine.hpp
View file @
810d3b43
...
...
@@ -49,6 +49,8 @@ class wss_engine_t : public ws_engine_t
const
char
*
hostname_
);
~
wss_engine_t
();
void
out_event
();
protected
:
bool
handshake
();
void
plug_internal
();
...
...
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