Coverage Report

Created: 2026-01-10 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/isc/helper.c
Line
Count
Source
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
 * SPDX-License-Identifier: MPL-2.0
5
 *
6
 * This Source Code Form is subject to the terms of the Mozilla Public
7
 * License, v. 2.0. If a copy of the MPL was not distributed with this
8
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9
 *
10
 * See the COPYRIGHT file distributed with this work for additional
11
 * information regarding copyright ownership.
12
 */
13
14
#include <stdlib.h>
15
#include <sys/types.h>
16
#include <unistd.h>
17
18
#include <isc/atomic.h>
19
#include <isc/barrier.h>
20
#include <isc/helper.h>
21
#include <isc/job.h>
22
#include <isc/loop.h>
23
#include <isc/magic.h>
24
#include <isc/mem.h>
25
#include <isc/mutex.h>
26
#include <isc/refcount.h>
27
#include <isc/result.h>
28
#include <isc/signal.h>
29
#include <isc/strerr.h>
30
#include <isc/thread.h>
31
#include <isc/util.h>
32
#include <isc/uv.h>
33
#include <isc/work.h>
34
35
#include "async_p.h"
36
#include "job_p.h"
37
#include "loop_p.h"
38
39
void
40
0
isc_helper_run(isc_loop_t *loop, isc_job_cb cb, void *cbarg) {
41
0
  REQUIRE(VALID_LOOP(loop));
42
0
  REQUIRE(cb != NULL);
43
44
0
  isc_loop_t *helper = isc_loop_helper(loop);
45
0
  isc_job_t *job = isc_mem_get(helper->mctx, sizeof(*job));
46
0
  *job = (isc_job_t){
47
0
    .cb = cb,
48
0
    .cbarg = cbarg,
49
0
  };
50
51
0
  cds_wfcq_node_init(&job->wfcq_node);
52
53
  /*
54
   * cds_wfcq_enqueue() is non-blocking and enqueues the job to async
55
   * queue.
56
   *
57
   * The function returns 'false' in case the queue was empty - in such
58
   * case we need to trigger the async callback.
59
   */
60
0
  if (!cds_wfcq_enqueue(&helper->async_jobs.head,
61
0
            &helper->async_jobs.tail, &job->wfcq_node))
62
0
  {
63
0
    int r = uv_async_send(&helper->async_trigger);
64
0
    UV_RUNTIME_CHECK(uv_async_send, r);
65
0
  }
66
0
}