Tiny simplification to dom_sid_string_buf
[Samba.git] / source3 / lib / server_contexts.c
bloba95ea9acc2ac0816aba4df0305b46ca5b345638e
1 /*
2 Unix SMB/CIFS implementation.
3 Common server globals
5 Copyright (C) Simo Sorce <idra@samba.org> 2010
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.
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.
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/>.
21 #include "includes.h"
22 #include "messages.h"
24 struct tevent_context *server_event_ctx = NULL;
26 struct tevent_context *server_event_context(void)
28 if (!server_event_ctx) {
30 * Note we MUST use the NULL context here, not the
31 * autofree context, to avoid side effects in forked
32 * children exiting.
34 server_event_ctx = s3_tevent_context_init(NULL);
36 if (!server_event_ctx) {
37 smb_panic("Could not init server's event context");
39 return server_event_ctx;
42 void server_event_context_free(void)
44 TALLOC_FREE(server_event_ctx);
47 struct messaging_context *server_msg_ctx = NULL;
49 struct messaging_context *server_messaging_context(void)
51 if (server_msg_ctx == NULL) {
53 * Note we MUST use the NULL context here, not the
54 * autofree context, to avoid side effects in forked
55 * children exiting.
57 server_msg_ctx = messaging_init(NULL,
58 procid_self(),
59 server_event_context());
61 return server_msg_ctx;
64 void server_messaging_context_free(void)
66 TALLOC_FREE(server_msg_ctx);