Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webui-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
webui-client
Commits
2ca45947
Unverified
Commit
2ca45947
authored
3 years ago
by
Tomáš Pecka
Browse files
Options
Downloads
Patches
Plain Diff
worker: fix timeval initialization
See
automata-library@172f6acd
parent
2bf3517a
No related branches found
No related tags found
2 merge requests
!27
0.2.0
,
!21
fetch list of algorithms (introspect) via API
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
worker/src/worker/runner.cpp
+9
-5
9 additions, 5 deletions
worker/src/worker/runner.cpp
with
9 additions
and
5 deletions
worker/src/worker/runner.cpp
+
9
−
5
View file @
2ca45947
...
@@ -13,17 +13,21 @@
...
@@ -13,17 +13,21 @@
#define FD_STDOUT 1
#define FD_STDOUT 1
#define FD_STDERR 2
#define FD_STDERR 2
using
namespace
std
::
chrono_literals
;
/* Communication between signal handler and the rest of the program */
/* Communication between signal handler and the rest of the program */
int
g_Wakeup
[
2
];
// pipe for wakeup
int
g_Wakeup
[
2
];
// pipe for wakeup
int
g_RecvSignal
;
// signalled flag
int
g_RecvSignal
;
// signalled flag
static
int
waitSignalTimeout
(
int
timeout
)
static
int
waitSignalTimeout
(
const
std
::
chrono
::
microseconds
&
duration
)
{
{
struct
timeval
tv
;
struct
timeval
tv
;
fd_set
rd
;
fd_set
rd
;
tv
.
tv_sec
=
0
;
auto
duration_secs
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
duration
);
tv
.
tv_usec
=
timeout
;
auto
duration_usecs
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
duration
-
duration_secs
);
tv
.
tv_sec
=
duration_secs
.
count
();
tv
.
tv_usec
=
duration_usecs
.
count
();
FD_ZERO
(
&
rd
);
FD_ZERO
(
&
rd
);
FD_SET
(
g_Wakeup
[
PIPE_RD
],
&
rd
);
FD_SET
(
g_Wakeup
[
PIPE_RD
],
&
rd
);
...
@@ -114,9 +118,9 @@ std::tuple<ResultType, std::string> _evaluate(const std::chrono::microseconds& t
...
@@ -114,9 +118,9 @@ std::tuple<ResultType, std::string> _evaluate(const std::chrono::microseconds& t
/* lets wait the specified time of microseconds, maybe the child will terminate on its own */
/* lets wait the specified time of microseconds, maybe the child will terminate on its own */
spdlog
::
debug
(
"Waiting for child. Timeout: {} us"
,
timeout
.
count
());
spdlog
::
debug
(
"Waiting for child. Timeout: {} us"
,
timeout
.
count
());
if
(
!
waitSignalTimeout
(
timeout
.
count
()
))
{
if
(
!
waitSignalTimeout
(
timeout
))
{
kill
(
pid
,
SIGTERM
);
kill
(
pid
,
SIGTERM
);
while
(
!
waitSignalTimeout
(
250
000
))
/* ... and in case it did not ..., SIGKILL it every 1/4 second */
while
(
!
waitSignalTimeout
(
250
ms
))
/* ... and in case it did not ..., SIGKILL it every 1/4 second */
kill
(
pid
,
SIGKILL
);
kill
(
pid
,
SIGKILL
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment