Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
Knot Resolver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jonathan Coetzee
Knot Resolver
Commits
2155907f
Verified
Commit
2155907f
authored
Jun 24, 2019
by
Vladimír Čunát
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modules/sd_watchdog: deinit correctness
and slightly better error reporting.
parent
94dc55af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
lib/utils.c
lib/utils.c
+5
-0
lib/utils.h
lib/utils.h
+4
-0
modules/sd_watchdog/sd_watchdog.c
modules/sd_watchdog/sd_watchdog.c
+17
-3
No files found.
lib/utils.c
View file @
2155907f
...
@@ -963,6 +963,11 @@ uint64_t kr_now()
...
@@ -963,6 +963,11 @@ uint64_t kr_now()
return
uv_now
(
uv_default_loop
());
return
uv_now
(
uv_default_loop
());
}
}
void
kr_uv_free_cb
(
uv_handle_t
*
handle
)
{
free
(
handle
->
data
);
}
const
char
*
kr_strptime_diff
(
const
char
*
format
,
const
char
*
time1_str
,
const
char
*
kr_strptime_diff
(
const
char
*
format
,
const
char
*
time1_str
,
const
char
*
time0_str
,
double
*
diff
)
{
const
char
*
time0_str
,
double
*
diff
)
{
assert
(
format
!=
NULL
);
assert
(
format
!=
NULL
);
...
...
lib/utils.h
View file @
2155907f
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include <libknot/packet/pkt.h>
#include <libknot/packet/pkt.h>
#include <libknot/rrset.h>
#include <libknot/rrset.h>
#include <libknot/rrtype/rrsig.h>
#include <libknot/rrtype/rrsig.h>
#include <uv.h>
#include "kresconfig.h"
#include "kresconfig.h"
#include "lib/generic/array.h"
#include "lib/generic/array.h"
...
@@ -478,6 +479,9 @@ static inline uint16_t kr_rrset_type_maysig(const knot_rrset_t *rr)
...
@@ -478,6 +479,9 @@ static inline uint16_t kr_rrset_type_maysig(const knot_rrset_t *rr)
KR_EXPORT
KR_EXPORT
uint64_t
kr_now
();
uint64_t
kr_now
();
/** Call free(handle->data); it's useful e.g. as a callback in uv_close(). */
KR_EXPORT
void
kr_uv_free_cb
(
uv_handle_t
*
handle
);
/** Convert name from lookup format to wire. See knot_dname_lf
/** Convert name from lookup format to wire. See knot_dname_lf
*
*
* \note len bytes are read and len+1 are written with *normal* LF,
* \note len bytes are read and len+1 are written with *normal* LF,
...
...
modules/sd_watchdog/sd_watchdog.c
View file @
2155907f
...
@@ -17,6 +17,7 @@ struct watchdog_config {
...
@@ -17,6 +17,7 @@ struct watchdog_config {
static
void
keepalive_ping
(
uv_timer_t
*
timer
)
static
void
keepalive_ping
(
uv_timer_t
*
timer
)
{
{
// NOTE: in the future, some sanity checks could be used here
// NOTE: in the future, some sanity checks could be used here
// It is generally recommended to ignore the return value of this call.
sd_notify
(
0
,
"WATCHDOG=1"
);
sd_notify
(
0
,
"WATCHDOG=1"
);
}
}
...
@@ -51,7 +52,9 @@ int sd_watchdog_init(struct kr_module *module)
...
@@ -51,7 +52,9 @@ int sd_watchdog_init(struct kr_module *module)
uv_timer_init
(
loop
,
&
conf
->
timer
);
uv_timer_init
(
loop
,
&
conf
->
timer
);
ret
=
uv_timer_start
(
&
conf
->
timer
,
keepalive_ping
,
delay_ms
,
delay_ms
);
ret
=
uv_timer_start
(
&
conf
->
timer
,
keepalive_ping
,
delay_ms
,
delay_ms
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
kr_log_error
(
"[sd_watchdog] error: failed to start uv_timer!
\n
"
);
kr_log_error
(
"[sd_watchdog] error: failed to start uv_timer: %s
\n
"
,
uv_strerror
(
ret
));
conf
->
timer
.
loop
=
NULL
;
return
kr_error
(
ret
);
return
kr_error
(
ret
);
}
}
...
@@ -64,8 +67,19 @@ int sd_watchdog_init(struct kr_module *module)
...
@@ -64,8 +67,19 @@ int sd_watchdog_init(struct kr_module *module)
KR_EXPORT
KR_EXPORT
int
sd_watchdog_deinit
(
struct
kr_module
*
module
)
int
sd_watchdog_deinit
(
struct
kr_module
*
module
)
{
{
struct
stat_data
*
conf
=
module
->
data
;
struct
watchdog_config
*
conf
=
module
->
data
;
if
(
conf
)
{
if
(
conf
&&
conf
->
timer
.
loop
==
uv_default_loop
())
{
/* normal state */
int
ret
=
uv_timer_stop
(
&
conf
->
timer
);
if
(
ret
!=
0
)
{
kr_log_error
(
"[sd_watchdog] error: failed to stop uv_timer: %s
\n
"
,
uv_strerror
(
ret
));
}
/* We have a problem: UV timer can't be closed immediately,
* but as soon as we return from _deinit(), we get dlclose()
* so no function from this module may be usable anymore. */
conf
->
timer
.
data
=
conf
;
uv_close
((
uv_handle_t
*
)
&
conf
->
timer
,
kr_uv_free_cb
);
}
else
{
/* watchdog might be just disabled */
free
(
conf
);
free
(
conf
);
}
}
return
kr_ok
();
return
kr_ok
();
...
...
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