Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
040a0e9b
Commit
040a0e9b
authored
4 years ago
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix server sometimes cannot exit
parent
02a6efaf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
simple_libevent_server.cpp
jlib/net/simple_libevent_server.cpp
+7
-2
No files found.
jlib/net/simple_libevent_server.cpp
View file @
040a0e9b
...
...
@@ -303,16 +303,19 @@ struct simple_libevent_server::PrivateImpl
simple_libevent_server
::
simple_libevent_server
()
{
AUTO_LOG_FUNCTION
;
SIMPLE_LIBEVENT_ONE_TIME_INITTER
;
}
simple_libevent_server
::~
simple_libevent_server
()
{
AUTO_LOG_FUNCTION
;
stop
();
}
bool
simple_libevent_server
::
start
(
uint16_t
port
,
std
::
string
&
msg
)
{
AUTO_LOG_FUNCTION
;
do
{
stop
();
...
...
@@ -384,11 +387,13 @@ bool simple_libevent_server::start(uint16_t port, std::string& msg)
void
simple_libevent_server
::
stop
()
{
AUTO_LOG_FUNCTION
;
std
::
lock_guard
<
std
::
mutex
>
lg
(
mutex
);
if
(
!
impl
)
{
return
;
}
if
(
impl
->
base
)
{
timeval
tv
{
0
,
1000
};
if
(
impl
->
base
)
{
event_base_loopexit
(
impl
->
base
,
&
tv
);
}
...
...
@@ -402,7 +407,7 @@ void simple_libevent_server::stop()
}
for
(
int
i
=
0
;
i
<
threadNum_
;
i
++
)
{
event_base_loopexit
(
impl
->
workerThreadContexts
[
i
]
->
base
,
nullptr
);
event_base_loopexit
(
impl
->
workerThreadContexts
[
i
]
->
base
,
&
tv
);
}
for
(
int
i
=
0
;
i
<
threadNum_
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
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