Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Knot projects
Knot DNS
Commits
d4743d1c
Commit
d4743d1c
authored
Jun 17, 2014
by
Jan Kadlec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
events: Fixed DDNS replan.
parent
a622526a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
src/knot/zone/events.c
src/knot/zone/events.c
+25
-9
src/knot/zone/zone.c
src/knot/zone/zone.c
+6
-1
No files found.
src/knot/zone/events.c
View file @
d4743d1c
...
...
@@ -389,9 +389,11 @@ static int event_update(zone_t *zone)
}
struct
request_data
*
update
=
zone_update_dequeue
(
zone
);
if
(
update
==
NULL
)
{
return
KNOT_EOK
;
}
/* Initialize query response. */
assert
(
update
);
assert
(
update
->
query
);
knot_pkt_init_response
(
resp
,
update
->
query
);
...
...
@@ -424,6 +426,16 @@ static int event_update(zone_t *zone)
/* Trim extra heap. */
mem_trim
();
/* Replan event if next update waiting. */
pthread_mutex_lock
(
&
zone
->
ddns_lock
);
if
(
!
EMPTY_LIST
(
zone
->
ddns_queue
))
{
zone_events_schedule
(
zone
,
ZONE_EVENT_UPDATE
,
ZONE_EVENT_NOW
);
}
pthread_mutex_unlock
(
&
zone
->
ddns_lock
);
return
KNOT_EOK
;
}
...
...
@@ -626,25 +638,29 @@ static void replan_flush(zone_t *zone, const zone_t *old_zone)
}
/*!< \brief Creates new DDNS q in the new zone - q contains references from the old zone. */
static
void
duplicate_ddns_q
(
zone_t
*
zone
,
const
zone_t
*
old_zone
)
static
void
duplicate_ddns_q
(
zone_t
*
zone
,
zone_t
*
old_zone
)
{
struct
request_data
*
d
;
WALK_LIST
(
d
,
old_zone
->
ddns_queue
)
{
struct
request_data
*
d
,
*
nxt
;
WALK_LIST
_DELSAFE
(
d
,
nxt
,
old_zone
->
ddns_queue
)
{
add_tail
(
&
zone
->
ddns_queue
,
(
node_t
*
)
d
);
}
// Reset the list, new zone will free the data.
init_list
(
&
((
zone_t
*
)
old_zone
)
->
ddns_queue
);
init_list
(
&
old_zone
->
ddns_queue
);
}
/*!< Replans DDNS event. */
static
void
replan_update
(
zone_t
*
zone
,
const
zone_t
*
old_zone
)
static
void
replan_update
(
zone_t
*
zone
,
zone_t
*
old_zone
)
{
pthread_mutex_lock
(
&
old_zone
->
ddns_lock
);
if
(
!
EMPTY_LIST
(
old_zone
->
ddns_queue
))
{
duplicate_ddns_q
(
zone
,
old_zone
);
duplicate_ddns_q
(
zone
,
(
zone_t
*
)
old_zone
);
// \todo #254 Old zone *must* have the event planned, but it was not always so
zone_events_schedule
(
zone
,
ZONE_EVENT_UPDATE
,
ZONE_EVENT_NOW
);
}
pthread_mutex_unlock
(
&
old_zone
->
ddns_lock
);
}
/*!< Replans DNSSEC event. Not whole resign needed, \todo #247 */
...
...
@@ -1029,14 +1045,14 @@ void zone_events_update(zone_t *zone, const zone_t *old_zone)
replan_xfer
(
zone
,
old_zone
);
replan_flush
(
zone
,
old_zone
);
replan_event
(
zone
,
old_zone
,
ZONE_EVENT_NOTIFY
);
replan_update
(
zone
,
old_zone
);
replan_update
(
zone
,
(
zone_t
*
)
old_zone
);
replan_dnssec
(
zone
);
}
void
zone_events_replan_ddns
(
struct
zone_t
*
zone
,
const
struct
zone_t
*
old_zone
)
{
if
(
old_zone
)
{
replan_update
(
zone
,
old_zone
);
replan_update
(
zone
,
(
zone_t
*
)
old_zone
);
}
}
src/knot/zone/zone.c
View file @
d4743d1c
...
...
@@ -315,7 +315,12 @@ struct request_data *zone_update_dequeue(zone_t *zone)
}
pthread_mutex_lock
(
&
zone
->
ddns_lock
);
assert
(
!
EMPTY_LIST
(
zone
->
ddns_queue
));
if
(
knot_unlikely
(
EMPTY_LIST
(
zone
->
ddns_queue
)))
{
/* Lost race during reload. */
pthread_mutex_unlock
(
&
zone
->
ddns_lock
);
return
NULL
;
}
struct
request_data
*
ret
=
HEAD
(
zone
->
ddns_queue
);
rem_node
((
node_t
*
)
ret
);
pthread_mutex_unlock
(
&
zone
->
ddns_lock
);
...
...
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