Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
77845cc0
Commit
77845cc0
authored
Mar 01, 2019
by
Libor Peltan
Committed by
Daniel Salzman
Apr 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: mutex avoid next update before cleanup by call_rcu
parent
00fa2fdd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
6 deletions
+38
-6
src/knot/updates/apply.c
src/knot/updates/apply.c
+9
-1
src/knot/updates/apply.h
src/knot/updates/apply.h
+4
-1
src/knot/updates/zone-update.c
src/knot/updates/zone-update.c
+10
-0
src/knot/zone/zone.c
src/knot/zone/zone.c
+5
-0
src/knot/zone/zone.h
src/knot/zone/zone.h
+3
-0
tests/knot/test_zone-update.c
tests/knot/test_zone-update.c
+7
-4
No files found.
src/knot/updates/apply.c
View file @
77845cc0
/* Copyright (C) 201
8
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
9
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -418,6 +418,10 @@ void update_cleanup(apply_ctx_t *ctx)
// also the nodes not being affected by the update itself
// might be affected
zone_trees_unify_binodes
(
ctx
->
contents
->
nodes
,
ctx
->
contents
->
nsec3_nodes
);
if
(
ctx
->
cow_mutex
!=
NULL
)
{
pthread_mutex_unlock
(
ctx
->
cow_mutex
);
}
}
void
update_rollback
(
apply_ctx_t
*
ctx
)
...
...
@@ -442,6 +446,10 @@ void update_rollback(apply_ctx_t *ctx)
trie_cow_rollback
(
ctx
->
contents
->
nsec3_nodes
->
cow
,
trie_cb_noop
,
NULL
);
}
if
(
ctx
->
cow_mutex
!=
NULL
)
{
pthread_mutex_unlock
(
ctx
->
cow_mutex
);
}
free
(
ctx
->
contents
->
nodes
);
free
(
ctx
->
contents
->
nsec3_nodes
);
...
...
src/knot/updates/apply.h
View file @
77845cc0
/* Copyright (C) 201
7
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
9
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -16,6 +16,8 @@
#pragma once
#include <pthread.h>
#include "knot/zone/contents.h"
#include "knot/updates/changesets.h"
#include "contrib/ucw/lists.h"
...
...
@@ -29,6 +31,7 @@ struct apply_ctx {
zone_tree_t
*
node_ptrs
;
/*!< Just pointers to the affected nodes in contents. */
zone_tree_t
*
nsec3_ptrs
;
/*!< The same for NSEC3 nodes. */
uint32_t
flags
;
pthread_mutex_t
*
cow_mutex
;
// pointer to zone_t struct
};
typedef
struct
apply_ctx
apply_ctx_t
;
...
...
src/knot/updates/zone-update.c
View file @
77845cc0
...
...
@@ -127,6 +127,9 @@ int init_base(zone_update_t *update, zone_t *zone, zone_contents_t *old_contents
return
KNOT_ENOMEM
;
}
pthread_mutex_lock
(
&
zone
->
cow_lock
);
update
->
a_ctx
->
cow_mutex
=
&
zone
->
cow_lock
;
int
ret
=
KNOT_EINVAL
;
if
(
flags
&
UPDATE_INCREMENTAL
)
{
ret
=
init_incremental
(
update
,
zone
,
old_contents
,
flags
&
UPDATE_JOURNAL
);
...
...
@@ -134,6 +137,7 @@ int init_base(zone_update_t *update, zone_t *zone, zone_contents_t *old_contents
ret
=
init_full
(
update
,
zone
);
}
if
(
ret
!=
KNOT_EOK
)
{
pthread_mutex_unlock
(
&
zone
->
cow_lock
);
free
(
update
->
a_ctx
);
}
...
...
@@ -217,6 +221,9 @@ int zone_update_from_contents(zone_update_t *update, zone_t *zone_without_conten
return
KNOT_ENOMEM
;
}
pthread_mutex_lock
(
&
update
->
zone
->
cow_lock
);
update
->
a_ctx
->
cow_mutex
=
&
update
->
zone
->
cow_lock
;
if
(
flags
&
UPDATE_INCREMENTAL
)
{
int
ret
=
changeset_init
(
&
update
->
change
,
zone_without_contents
->
name
);
if
(
ret
!=
KNOT_EOK
)
{
...
...
@@ -335,6 +342,9 @@ void zone_update_clear(zone_update_t *update)
update_cleanup
(
update
->
a_ctx
);
zone_contents_deep_free
(
update
->
new_cont
);
}
if
(
update
->
a_ctx
!=
NULL
&&
update
->
a_ctx
->
cow_mutex
!=
NULL
)
{
pthread_mutex_unlock
(
update
->
a_ctx
->
cow_mutex
);
}
free
(
update
->
a_ctx
);
mp_delete
(
update
->
mm
.
ctx
);
memset
(
update
,
0
,
sizeof
(
*
update
));
...
...
src/knot/zone/zone.c
View file @
77845cc0
...
...
@@ -175,6 +175,8 @@ zone_t* zone_new(const knot_dname_t *name)
zone
->
ddns_queue_size
=
0
;
init_list
(
&
zone
->
ddns_queue
);
pthread_mutex_init
(
&
zone
->
cow_lock
,
NULL
);
// Preferred master lock
pthread_mutex_init
(
&
zone
->
preferred_lock
,
NULL
);
...
...
@@ -213,6 +215,9 @@ void zone_free(zone_t **zone_ptr)
free_ddns_queue
(
zone
);
pthread_mutex_destroy
(
&
zone
->
ddns_lock
);
pthread_mutex_lock
(
&
zone
->
cow_lock
);
pthread_mutex_destroy
(
&
zone
->
cow_lock
);
/* Control update. */
zone_control_clear
(
zone
);
...
...
src/knot/zone/zone.h
View file @
77845cc0
...
...
@@ -71,6 +71,9 @@ typedef struct zone
/*! \brief Control update context. */
struct
zone_update
*
control_update
;
/*! \brief Ensue one COW tramsaction on zone's trees at a time. */
pthread_mutex_t
cow_lock
;
/*! \brief Ptr to journal DB (in struct server) */
knot_lmdb_db_t
*
journaldb
;
...
...
tests/knot/test_zone-update.c
View file @
77845cc0
...
...
@@ -15,6 +15,7 @@
*/
#include <assert.h>
#include <pthread.h>
#include <tap/basic.h>
#include <tap/files.h>
#include <unistd.h>
...
...
@@ -105,9 +106,11 @@ static int test_node_unified(zone_node_t *n1, void *v)
return
KNOT_EOK
;
}
static
void
test_zone_unified
(
zone_
contents_
t
*
z
)
static
void
test_zone_unified
(
zone_t
*
z
)
{
zone_tree_apply
(
z
->
nodes
,
test_node_unified
,
NULL
);
pthread_mutex_lock
(
&
z
->
cow_lock
);
zone_tree_apply
(
z
->
contents
->
nodes
,
test_node_unified
,
NULL
);
pthread_mutex_unlock
(
&
z
->
cow_lock
);
}
void
test_full
(
zone_t
*
zone
,
zs_scanner_t
*
sc
)
...
...
@@ -223,7 +226,7 @@ void test_full(zone_t *zone, zs_scanner_t *sc)
rrset_present
=
node_contains_rr
(
node
,
&
rrset
);
ok
(
ret
==
KNOT_EOK
&&
rrset_present
,
"full zone update: commit"
);
test_zone_unified
(
zone
->
contents
);
test_zone_unified
(
zone
);
knot_rdataset_clear
(
&
rrset
.
rrs
,
NULL
);
}
...
...
@@ -325,7 +328,7 @@ void test_incremental(zone_t *zone, zs_scanner_t *sc)
rrset_present
=
node_contains_rr
(
iter_node
,
&
rrset
);
ok
(
ret
==
KNOT_EOK
&&
rrset_present
,
"incremental zone update: commit"
);
test_zone_unified
(
zone
->
contents
);
test_zone_unified
(
zone
);
knot_rdataset_clear
(
&
rrset
.
rrs
,
NULL
);
}
...
...
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