Coverage Report

Created: 2025-11-11 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/isc/job.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/job.h>
21
#include <isc/list.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 "job_p.h"
36
#include "loop_p.h"
37
#include "probes-isc.h"
38
39
/*
40
 * Public: #include <isc/job.h>
41
 */
42
43
void
44
0
isc_job_run(isc_loop_t *loop, isc_job_t *job, isc_job_cb cb, void *cbarg) {
45
0
  if (ISC_LIST_EMPTY(loop->run_jobs)) {
46
0
    uv_idle_start(&loop->run_trigger, isc__job_cb);
47
0
  }
48
49
0
  job->cb = cb;
50
0
  job->cbarg = cbarg;
51
0
  ISC_LINK_INIT(job, link);
52
53
0
  ISC_LIST_APPEND(loop->run_jobs, job, link);
54
0
}
55
56
/*
57
 * Protected: #include <job_p.h>
58
 */
59
60
void
61
0
isc__job_cb(uv_idle_t *handle) {
62
0
  isc_loop_t *loop = uv_handle_get_data(handle);
63
0
  ISC_LIST(isc_job_t) jobs = ISC_LIST_INITIALIZER;
64
65
0
  ISC_LIST_MOVE(jobs, loop->run_jobs);
66
67
0
  ISC_LIST_FOREACH(jobs, job, link) {
68
0
    isc_job_cb cb = job->cb;
69
0
    void *cbarg = job->cbarg;
70
0
    ISC_LIST_UNLINK(jobs, job, link);
71
0
    LIBISC_JOB_CB_BEFORE(job, cb, cbarg);
72
0
    cb(cbarg);
73
0
    LIBISC_JOB_CB_AFTER(job, cb, cbarg);
74
0
  }
75
76
0
  if (ISC_LIST_EMPTY(loop->run_jobs)) {
77
0
    uv_idle_stop(&loop->run_trigger);
78
0
  }
79
0
}
80
81
void
82
0
isc__job_close(uv_handle_t *handle) {
83
0
  isc_loop_t *loop = uv_handle_get_data(handle);
84
85
0
  isc__job_cb(&loop->run_trigger);
86
0
}