LCOV - code coverage report
Current view: top level - source3/lib - global_contexts.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 15 16 93.8 %
Date: 2021-09-23 10:06:22 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     2162219 : struct tevent_context *global_event_context(void)
      32             : {
      33     2162219 :         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        4266 :                 global_event_ctx = samba_tevent_context_init(NULL);
      40             :         }
      41     2162219 :         if (!global_event_ctx) {
      42           0 :                 smb_panic("Could not init global event context");
      43             :         }
      44     2162219 :         return global_event_ctx;
      45             : }
      46             : 
      47       27245 : void global_event_context_free(void)
      48             : {
      49       27245 :         TALLOC_FREE(global_event_ctx);
      50       27245 : }
      51             : 
      52             : static struct messaging_context *global_msg_ctx = NULL;
      53             : 
      54       54963 : struct messaging_context *global_messaging_context(void)
      55             : {
      56       54963 :         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        4233 :                 global_msg_ctx = messaging_init(NULL,
      63             :                                                 global_event_context());
      64             :         }
      65       54963 :         return global_msg_ctx;
      66             : }
      67             : 
      68       30741 : void global_messaging_context_free(void)
      69             : {
      70       30741 :         TALLOC_FREE(global_msg_ctx);
      71       30741 : }

Generated by: LCOV version 1.13