Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
200ade32
Unverified
Commit
200ade32
authored
Jun 10, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-4284
parent
ed66780a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
34 deletions
+11
-34
ZMQServer.cpp
ZMQServer.cpp
+10
-31
ZMQServer.h
ZMQServer.h
+1
-3
No files found.
ZMQServer.cpp
View file @
200ade32
...
...
@@ -40,10 +40,10 @@ shared_ptr <ZMQServer> ZMQServer::zmqServer = nullptr;
ZMQServer
::
ZMQServer
(
bool
_checkSignature
,
const
string
&
_caCertFile
)
:
checkSignature
(
_checkSignature
),
caCertFile
(
_caCertFile
),
ctx
_
(
make_shared
<
zmq
::
context_t
>
(
1
))
{
caCertFile
(
_caCertFile
),
ctx
(
make_shared
<
zmq
::
context_t
>
(
1
))
{
socket
=
make_shared
<
zmq
::
socket_t
>
(
*
ctx
_
,
ZMQ_ROUTER
);
socket
=
make_shared
<
zmq
::
socket_t
>
(
*
ctx
,
ZMQ_ROUTER
);
if
(
_checkSignature
)
{
CHECK_STATE
(
!
_caCertFile
.
empty
());
...
...
@@ -84,25 +84,19 @@ void ZMQServer::run() {
}
}
}
spdlog
::
info
(
"Exited zmq server loop"
);
void
ZMQServer
::
exitAll
()
{
}
std
::
atomic
<
bool
>
ZMQServer
::
isExitRequested
(
false
);
void
ZMQServer
::
exitZMQServer
()
{
auto
doExit
=
!
isExitRequested
.
exchange
(
true
);
if
(
doExit
)
{
zmqServer
->
exitAll
();
spdlog
::
info
(
"deleting zmq server"
);
zmqServer
=
nullptr
;
spdlog
::
info
(
"deleted zmq server "
);
}
isExitRequested
.
exchange
(
true
);
zmqServer
->
ctx
->
shutdown
();
zmqServer
->
socket
->
close
();
zmqServer
->
ctx
->
close
();
spdlog
::
info
(
"Exited zmq server."
);
}
...
...
@@ -116,7 +110,6 @@ void ZMQServer::initZMQServer(bool _checkSignature) {
string
rootCAPath
=
""
;
if
(
_checkSignature
)
{
rootCAPath
=
string
(
SGXDATA_FOLDER
)
+
"cert_data/rootCA.pem"
;
spdlog
::
info
(
"Reading root CA from {}"
,
rootCAPath
);
CHECK_STATE
(
access
(
rootCAPath
.
c_str
(),
F_OK
)
==
0
);
...
...
@@ -132,23 +125,11 @@ void ZMQServer::initZMQServer(bool _checkSignature) {
spdlog
::
info
(
"Inited zmq server ..."
);
}
shared_ptr
<
std
::
thread
>
ZMQServer
::
serverThread
=
nullptr
;
ZMQServer
::~
ZMQServer
()
{
spdlog
::
info
(
"Deleting front end"
);
socket
=
nullptr
;
spdlog
::
info
(
"Deleted front end"
);
spdlog
::
info
(
"Deleting ZMQ context"
);
ctx_
=
nullptr
;
spdlog
::
info
(
"Deleted ZMQ context"
);
}
...
...
@@ -222,9 +203,7 @@ void ZMQServer::doOneServerLoop() {
result
[
"errorMessage"
]
=
e
.
what
();
spdlog
::
error
(
"Exception in zmq server {}"
,
e
.
what
());
}
catch
(
std
::
exception
&
e
)
{
catch
(
std
::
exception
&
e
)
{
if
(
isExitRequested
)
{
return
;
}
...
...
ZMQServer.h
View file @
200ade32
...
...
@@ -58,15 +58,13 @@ public:
void
run
();
void
exitAll
();
static
void
initZMQServer
(
bool
_checkSignature
);
static
void
exitZMQServer
();
private
:
shared_ptr
<
zmq
::
context_t
>
ctx
_
;
shared_ptr
<
zmq
::
context_t
>
ctx
;
shared_ptr
<
zmq
::
socket_t
>
socket
;
static
std
::
atomic
<
bool
>
isExitRequested
;
...
...
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