s3:smbd move messaging_context and memcache into globals.c
authorAndrew Bartlett <abartlet@samba.org>
Wed, 26 May 2010 00:48:15 +0000 (10:48 +1000)
committerStefan Metzmacher <metze@samba.org>
Fri, 28 May 2010 16:08:27 +0000 (18:08 +0200)
This helps vfstest, which previously had duplicate copies of these functions.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/globals.c
source3/smbd/server.c
source3/torture/vfstest.c

index 10ee5e81e28138e50c7b524ce460d254e93fa822..892bc89d0840151737b5c5cc82f499184da7ec2e 100644 (file)
@@ -125,6 +125,33 @@ int num_children = 0;
 
 struct smbd_server_connection *smbd_server_conn = NULL;
 
+struct messaging_context *smbd_messaging_context(void)
+{
+       if (smbd_msg_ctx == NULL) {
+               smbd_msg_ctx = messaging_init(talloc_autofree_context(),
+                                             procid_self(),
+                                             smbd_event_context());
+       }
+       if (smbd_msg_ctx == NULL) {
+               DEBUG(0, ("Could not init smbd messaging context.\n"));
+       }
+       return smbd_msg_ctx;
+}
+
+struct memcache *smbd_memcache(void)
+{
+       if (!smbd_memcache_ctx) {
+               smbd_memcache_ctx = memcache_init(talloc_autofree_context(),
+                                                 lp_max_stat_cache_size()*1024);
+       }
+       if (!smbd_memcache_ctx) {
+               smb_panic("Could not init smbd memcache");
+       }
+
+       return smbd_memcache_ctx;
+}
+
+
 void smbd_init_globals(void)
 {
        ZERO_STRUCT(char_flags);
index 0e3ec1d033ae38d1f87002eef9d1f1c44f59831a..184b613810d939f349a5d43c0b12316433eafbb9 100644 (file)
@@ -58,32 +58,6 @@ struct event_context *smbd_event_context(void)
        return smbd_event_ctx;
 }
 
-struct messaging_context *smbd_messaging_context(void)
-{
-       if (smbd_msg_ctx == NULL) {
-               smbd_msg_ctx = messaging_init(talloc_autofree_context(),
-                                             procid_self(),
-                                             smbd_event_context());
-       }
-       if (smbd_msg_ctx == NULL) {
-               DEBUG(0, ("Could not init smbd messaging context.\n"));
-       }
-       return smbd_msg_ctx;
-}
-
-struct memcache *smbd_memcache(void)
-{
-       if (!smbd_memcache_ctx) {
-               smbd_memcache_ctx = memcache_init(talloc_autofree_context(),
-                                                 lp_max_stat_cache_size()*1024);
-       }
-       if (!smbd_memcache_ctx) {
-               smb_panic("Could not init smbd memcache");
-       }
-
-       return smbd_memcache_ctx;
-}
-
 /*******************************************************************
  What to do when smb.conf is updated.
  ********************************************************************/
index c885163729ab5b0269c92f4f164a30ca7712dec7..ea18bb395e220fcfcec46421c6b982894a669d91 100644 (file)
@@ -432,30 +432,6 @@ struct event_context *smbd_event_context(void)
        return ctx;
 }
 
-struct messaging_context *smbd_messaging_context(void)
-{
-       static struct messaging_context *ctx;
-
-       if (!ctx && !(ctx = messaging_init(NULL, procid_self(),
-                                          smbd_event_context()))) {
-               smb_panic("Could not init smbd messaging context\n");
-       }
-       return ctx;
-}
-
-struct memcache *smbd_memcache(void)
-{
-       static struct memcache *cache;
-
-       if (!cache
-           && !(cache = memcache_init(NULL,
-                                      lp_max_stat_cache_size()*1024))) {
-
-               smb_panic("Could not init smbd memcache");
-       }
-       return cache;
-}
-
 /* Main function */
 
 int main(int argc, char *argv[])