Debian Codegraph @

res/res_aeap/general.c

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2021, Sangoma Technologies Corporation
5 *
6 * Kevin Harwell <[email protected]>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19 #include "asterisk.h"
20
21 #include "asterisk/astobj2.h"
22 #include "asterisk/sched.h"
23
24 #include "general.h"
25
26 /*! \brief Scheduler for transaction timeouts */
27 static struct ast_sched_context *sched = NULL;
28
29 struct ast_sched_context *aeap_sched_context(void)
30 {
31 return sched;
32 }
33
34 void aeap_general_finalize(void)
35 {
36 if (sched) {
37 ast_sched_context_destroy(sched);
38 sched = NULL;
39 }
40 }
41
42 int aeap_general_initialize(void)
43 {
44 sched = ast_sched_context_create();
45 if (!sched) {
46 ast_log(LOG_ERROR, "AEAP scheduler: unable to create context");
47 return -1;
48 }
49
50 if (ast_sched_start_thread(sched)) {
51 ast_log(LOG_ERROR, "AEAP scheduler: unable to start thread");
52 aeap_general_finalize();
53 return -1;
54 }
55
56 return 0;
57 }
58