LCOV - code coverage report
Current view: top level - source3/lib - global_contexts.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 15 16 93.8 %
Date: 2024-04-21 15:09:00 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Global contexts
       4             : 
       5             :    Copyright (C) Simo Sorce <idra@samba.org> 2010
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : 
      22             : #include "replace.h"
      23             : #include "global_contexts.h"
      24             : #include <tevent.h>
      25             : #include "lib/util/fault.h"
      26             : #include "lib/util/samba_util.h"
      27             : #include "messages.h"
      28             : 
      29             : static struct tevent_context *global_event_ctx = NULL;
      30             : 
      31     2915082 : struct tevent_context *global_event_context(void)
      32             : {
      33     2915082 :         if (!global_event_ctx) {
      34             :                 /*
      35             :                  * Note we MUST use the NULL context here, not the
      36             :                  * autofree context, to avoid side effects in forked
      37             :                  * children exiting.
      38             :                  */
      39        5073 :                 global_event_ctx = samba_tevent_context_init(NULL);
      40             :         }
      41     2915082 :         if (!global_event_ctx) {
      42           0 :                 smb_panic("Could not init global event context");
      43             :         }
      44     2915082 :         return global_event_ctx;
      45             : }
      46             : 
      47       31551 : void global_event_context_free(void)
      48             : {
      49       31551 :         TALLOC_FREE(global_event_ctx);
      50       31551 : }
      51             : 
      52             : static struct messaging_context *global_msg_ctx = NULL;
      53             : 
      54       85204 : struct messaging_context *global_messaging_context(void)
      55             : {
      56       85204 :         if (global_msg_ctx == NULL) {
      57             :                 /*
      58             :                  * Note we MUST use the NULL context here, not the
      59             :                  * autofree context, to avoid side effects in forked
      60             :                  * children exiting.
      61             :                  */
      62        5030 :                 global_msg_ctx = messaging_init(NULL,
      63             :                                                 global_event_context());
      64             :         }
      65       85204 :         return global_msg_ctx;
      66             : }
      67             : 
      68       35283 : void global_messaging_context_free(void)
      69             : {
      70       35283 :         TALLOC_FREE(global_msg_ctx);
      71       35283 : }

Generated by: LCOV version 1.14