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
4c3f1154
Commit
4c3f1154
authored
Dec 11, 2019
by
Simon Giesecke
Committed by
Simon Giesecke
Dec 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: raw malloc used unnecessarily
Solution: use std::string instead
parent
30e2398e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
28 deletions
+18
-28
session_base.cpp
src/session_base.cpp
+3
-16
session_base.hpp
src/session_base.hpp
+1
-1
ws_connecter.cpp
src/ws_connecter.cpp
+1
-1
ws_connecter.hpp
src/ws_connecter.hpp
+2
-2
ws_listener.cpp
src/ws_listener.cpp
+3
-2
wss_engine.cpp
src/wss_engine.cpp
+7
-5
wss_engine.hpp
src/wss_engine.hpp
+1
-1
No files found.
src/session_base.cpp
View file @
4c3f1154
...
...
@@ -117,17 +117,9 @@ zmq::session_base_t::session_base_t (class io_thread_t *io_thread_,
_addr
(
addr_
)
#ifdef ZMQ_HAVE_WSS
,
_wss_hostname
(
NULL
)
_wss_hostname
(
options_
.
wss_hostname
)
#endif
{
#ifdef ZMQ_HAVE_WSS
if
(
options_
.
wss_hostname
.
length
()
>
0
)
{
_wss_hostname
=
static_cast
<
char
*>
(
malloc
(
options_
.
wss_hostname
.
length
()
+
1
));
assert
(
_wss_hostname
);
strcpy
(
_wss_hostname
,
options_
.
wss_hostname
.
c_str
());
}
#endif
}
const
zmq
::
endpoint_uri_pair_t
&
zmq
::
session_base_t
::
get_endpoint
()
const
...
...
@@ -150,11 +142,6 @@ zmq::session_base_t::~session_base_t ()
if
(
_engine
)
_engine
->
terminate
();
#ifdef ZMQ_HAVE_WSS
if
(
_wss_hostname
)
free
(
_wss_hostname
);
#endif
LIBZMQ_DELETE
(
_addr
);
}
...
...
@@ -708,8 +695,8 @@ zmq::own_t *zmq::session_base_t::create_connecter_tcp (io_thread_t *io_thread_,
zmq
::
own_t
*
zmq
::
session_base_t
::
create_connecter_ws
(
io_thread_t
*
io_thread_
,
bool
wait_
)
{
return
new
(
std
::
nothrow
)
ws_connecter_t
(
io_thread_
,
this
,
options
,
_addr
,
wait_
,
false
,
NULL
);
return
new
(
std
::
nothrow
)
ws_connecter_t
(
io_thread_
,
this
,
options
,
_addr
,
wait_
,
false
,
std
::
string
()
);
}
#endif
...
...
src/session_base.hpp
View file @
4c3f1154
...
...
@@ -195,7 +195,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
#ifdef ZMQ_HAVE_WSS
// TLS handshake, we need to take a copy when the session is created,
// in order to maintain the value at the creation time
c
har
*
_wss_hostname
;
c
onst
std
::
string
_wss_hostname
;
#endif
ZMQ_NON_COPYABLE_NOR_MOVABLE
(
session_base_t
)
...
...
src/ws_connecter.cpp
View file @
4c3f1154
...
...
@@ -74,7 +74,7 @@ zmq::ws_connecter_t::ws_connecter_t (class io_thread_t *io_thread_,
address_t
*
addr_
,
bool
delayed_start_
,
bool
wss_
,
const
char
*
tls_hostname_
)
:
const
std
::
string
&
tls_hostname_
)
:
stream_connecter_base_t
(
io_thread_
,
session_
,
options_
,
addr_
,
delayed_start_
),
_connect_timer_started
(
false
),
...
...
src/ws_connecter.hpp
View file @
4c3f1154
...
...
@@ -47,7 +47,7 @@ class ws_connecter_t : public stream_connecter_base_t
address_t
*
addr_
,
bool
delayed_start_
,
bool
wss_
,
const
char
*
tls_hostname_
);
const
std
::
string
&
tls_hostname_
);
~
ws_connecter_t
();
protected
:
...
...
@@ -89,7 +89,7 @@ class ws_connecter_t : public stream_connecter_base_t
bool
_connect_timer_started
;
bool
_wss
;
const
char
*
_hostname
;
const
std
::
string
&
_hostname
;
ZMQ_NON_COPYABLE_NOR_MOVABLE
(
ws_connecter_t
)
};
...
...
src/ws_listener.cpp
View file @
4c3f1154
...
...
@@ -294,8 +294,9 @@ void zmq::ws_listener_t::create_engine (fd_t fd_)
i_engine
*
engine
=
NULL
;
if
(
_wss
)
#ifdef ZMQ_HAVE_WSS
engine
=
new
(
std
::
nothrow
)
wss_engine_t
(
fd_
,
options
,
endpoint_pair
,
_address
,
false
,
_tls_cred
,
NULL
);
engine
=
new
(
std
::
nothrow
)
wss_engine_t
(
fd_
,
options
,
endpoint_pair
,
_address
,
false
,
_tls_cred
,
std
::
string
());
#else
assert
(
false
);
#endif
...
...
src/wss_engine.cpp
View file @
4c3f1154
...
...
@@ -58,7 +58,7 @@ zmq::wss_engine_t::wss_engine_t (fd_t fd_,
ws_address_t
&
address_
,
bool
client_
,
void
*
tls_server_cred_
,
const
char
*
hostname_
)
:
const
std
::
string
&
hostname_
)
:
ws_engine_t
(
fd_
,
options_
,
endpoint_uri_pair_
,
address_
,
client_
),
_established
(
false
),
_tls_client_cred
(
NULL
)
...
...
@@ -88,11 +88,13 @@ zmq::wss_engine_t::wss_engine_t (fd_t fd_,
rc
=
gnutls_init
(
&
_tls_session
,
GNUTLS_CLIENT
|
GNUTLS_NONBLOCK
);
assert
(
rc
==
GNUTLS_E_SUCCESS
);
if
(
hostname_
)
gnutls_server_name_set
(
_tls_session
,
GNUTLS_NAME_DNS
,
hostname_
,
strlen
(
hostname_
));
if
(
!
hostname_
.
empty
()
)
gnutls_server_name_set
(
_tls_session
,
GNUTLS_NAME_DNS
,
hostname_
.
c_str
(),
hostname_
.
size
(
));
gnutls_session_set_ptr
(
_tls_session
,
(
void
*
)
hostname_
);
gnutls_session_set_ptr
(
_tls_session
,
hostname_
.
empty
()
?
NULL
:
const_cast
<
char
*>
(
hostname_
.
c_str
()));
rc
=
gnutls_credentials_set
(
_tls_session
,
GNUTLS_CRD_CERTIFICATE
,
_tls_client_cred
);
...
...
src/wss_engine.hpp
View file @
4c3f1154
...
...
@@ -46,7 +46,7 @@ class wss_engine_t : public ws_engine_t
ws_address_t
&
address_
,
bool
client_
,
void
*
tls_server_cred_
,
const
char
*
hostname_
);
const
std
::
string
&
hostname_
);
~
wss_engine_t
();
void
out_event
();
...
...
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