Commit d87ad693 authored by Mark Andrews's avatar Mark Andrews

2377. [bug] Address race condition in dnssec-signzone. [RT #18142]

parent 9d362f90
2377. [bug] Address race condition in dnssec-signzone. [RT #18142]
2376. [bug] Change #2144 was not complete.
2375. [placeholder]
......
......@@ -29,7 +29,7 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-signzone.c,v 1.204 2007/08/28 07:20:42 tbox Exp $ */
/* $Id: dnssec-signzone.c,v 1.205 2008/06/02 00:17:39 marka Exp $ */
/*! \file */
......@@ -141,7 +141,6 @@ static dns_name_t *gorigin; /* The database origin */
static isc_task_t *master = NULL;
static unsigned int ntasks = 0;
static isc_boolean_t shuttingdown = ISC_FALSE, finished = ISC_FALSE;
static unsigned int assigned = 0, completed = 0;
static isc_boolean_t nokeys = ISC_FALSE;
static isc_boolean_t removefile = ISC_FALSE;
static isc_boolean_t generateds = ISC_FALSE;
......@@ -1237,16 +1236,19 @@ assignwork(isc_task_t *task, isc_task_t *worker) {
dns_rdataset_t nsec;
isc_boolean_t found;
isc_result_t result;
static unsigned int ended = 0; /* Protected by namelock. */
if (shuttingdown)
return;
LOCK(&namelock);
if (finished) {
if (assigned == completed) {
ended++;
if (ended == ntasks) {
isc_task_detach(&task);
isc_app_shutdown();
}
return;
goto unlock;
}
fname = isc_mem_get(mctx, sizeof(dns_fixedname_t));
......@@ -1256,7 +1258,6 @@ assignwork(isc_task_t *task, isc_task_t *worker) {
name = dns_fixedname_name(fname);
node = NULL;
found = ISC_FALSE;
LOCK(&namelock);
while (!found) {
result = dns_dbiterator_current(gdbiter, &node, name);
if (result != ISC_R_SUCCESS)
......@@ -1283,14 +1284,14 @@ assignwork(isc_task_t *task, isc_task_t *worker) {
fatal("failure iterating database: %s",
isc_result_totext(result));
}
UNLOCK(&namelock);
if (!found) {
if (assigned == completed) {
ended++;
if (ended == ntasks) {
isc_task_detach(&task);
isc_app_shutdown();
}
isc_mem_put(mctx, fname, sizeof(dns_fixedname_t));
return;
goto unlock;
}
sevent = (sevent_t *)
isc_event_allocate(mctx, task, SIGNER_EVENT_WORK,
......@@ -1301,7 +1302,8 @@ assignwork(isc_task_t *task, isc_task_t *worker) {
sevent->node = node;
sevent->fname = fname;
isc_task_send(worker, ISC_EVENT_PTR(&sevent));
assigned++;
unlock:
UNLOCK(&namelock);
}
/*%
......@@ -1324,7 +1326,6 @@ writenode(isc_task_t *task, isc_event_t *event) {
isc_task_t *worker;
sevent_t *sevent = (sevent_t *)event;
completed++;
worker = (isc_task_t *)event->ev_sender;
dumpnode(dns_fixedname_name(sevent->fname), sevent->node);
cleannode(gdb, gversion, sevent->node);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment