summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-08-10 12:29:27 +0200
committerSimo Sorce <idra@samba.org>2010-08-13 12:20:10 -0400
commitaff002e829b8169997f7f446959e2f1d5baf3a60 (patch)
treeab5983a8cdc8067d80cc313f7df7946b114ec274 /source3/smbd
parent62a2a9e27f8983717f13dbe3d92b21ed4b9bf22e (diff)
downloadsamba-aff002e829b8169997f7f446959e2f1d5baf3a60.tar.gz
samba-aff002e829b8169997f7f446959e2f1d5baf3a60.tar.bz2
samba-aff002e829b8169997f7f446959e2f1d5baf3a60.zip
s3-smbd: Move rpc services init to smbd parent.
The move to the parent makes it possible to use an internal rpc pipe really early and as we migrated serveral parts of samba to rpc function this is required. This should speed up the fork of a smbd a bit cause the rpc services are already running. We still have several problems here which aren't solved. We don't have a dependency tree here. For example we have to make sure that the registry is initialized before we can use the winreg pipe. The spoolss server requires winreg, so we have to start winreg before we can start the spoolss server. I'm sure there are more dependencies. Signed-off-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/process.c43
-rw-r--r--source3/smbd/server.c45
2 files changed, 46 insertions, 42 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index adfcad1bdc..61db7129b1 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -20,22 +20,8 @@
#include "includes.h"
#include "smbd/globals.h"
-#include "../librpc/gen_ndr/srv_dfs.h"
-#include "../librpc/gen_ndr/srv_dssetup.h"
-#include "../librpc/gen_ndr/srv_echo.h"
-#include "../librpc/gen_ndr/srv_eventlog.h"
-#include "../librpc/gen_ndr/srv_initshutdown.h"
-#include "../librpc/gen_ndr/srv_lsa.h"
-#include "../librpc/gen_ndr/srv_netlogon.h"
-#include "../librpc/gen_ndr/srv_ntsvcs.h"
-#include "../librpc/gen_ndr/srv_samr.h"
-#include "../librpc/gen_ndr/srv_spoolss.h"
-#include "../librpc/gen_ndr/srv_srvsvc.h"
-#include "../librpc/gen_ndr/srv_svcctl.h"
-#include "../librpc/gen_ndr/srv_winreg.h"
-#include "../librpc/gen_ndr/srv_wkssvc.h"
+#include "librpc/gen_ndr/netlogon.h"
#include "librpc/gen_ndr/messaging.h"
-#include "printing/nt_printing_migrate.h"
extern bool global_machine_password_needs_changing;
@@ -2868,13 +2854,6 @@ fail:
return false;
}
-static bool spoolss_init_cb(void *ptr)
-{
- struct messaging_context *msg_ctx = talloc_get_type_abort(
- ptr, struct messaging_context);
- return nt_printing_tdb_migrate(msg_ctx);
-}
-
/****************************************************************************
Process commands from the client
****************************************************************************/
@@ -2889,7 +2868,6 @@ void smbd_process(struct smbd_server_connection *sconn)
struct tsocket_address *remote_address = NULL;
const char *remaddr = NULL;
int ret;
- struct rpc_srv_callbacks spoolss_cb;
if (lp_maxprotocol() == PROTOCOL_SMB2 &&
lp_security() != SEC_SHARE &&
@@ -3127,25 +3105,6 @@ void smbd_process(struct smbd_server_connection *sconn)
exit_server("failed to create smbd_server_connection fde");
}
- /*
- * Initialize spoolss with an init function to convert printers first.
- * static_init_rpc will try to initialize the spoolss server too but you
- * can't register it twice.
- */
- spoolss_cb.init = spoolss_init_cb;
- spoolss_cb.shutdown = NULL;
- spoolss_cb.private_data = sconn->msg_ctx;
-
- if (!NT_STATUS_IS_OK(rpc_winreg_init(NULL))) {
- exit(1);
- }
-
- if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
- exit(1);
- }
-
- static_init_rpc;
-
TALLOC_FREE(frame);
while (True) {
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 90756e1df2..ca6f6c8e16 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -29,6 +29,23 @@
#include "libcli/auth/schannel.h"
#include "secrets.h"
+#include "../librpc/gen_ndr/srv_dfs.h"
+#include "../librpc/gen_ndr/srv_dssetup.h"
+#include "../librpc/gen_ndr/srv_echo.h"
+#include "../librpc/gen_ndr/srv_eventlog.h"
+#include "../librpc/gen_ndr/srv_initshutdown.h"
+#include "../librpc/gen_ndr/srv_lsa.h"
+#include "../librpc/gen_ndr/srv_netlogon.h"
+#include "../librpc/gen_ndr/srv_ntsvcs.h"
+#include "../librpc/gen_ndr/srv_samr.h"
+#include "../librpc/gen_ndr/srv_spoolss.h"
+#include "../librpc/gen_ndr/srv_srvsvc.h"
+#include "../librpc/gen_ndr/srv_svcctl.h"
+#include "../librpc/gen_ndr/srv_winreg.h"
+#include "../librpc/gen_ndr/srv_wkssvc.h"
+
+#include "printing/nt_printing_migrate.h"
+
static_decl_rpc;
#ifdef WITH_DFS
@@ -767,6 +784,13 @@ static bool init_structs(void )
return True;
}
+static bool spoolss_init_cb(void *ptr)
+{
+ struct messaging_context *msg_ctx = talloc_get_type_abort(
+ ptr, struct messaging_context);
+ return nt_printing_tdb_migrate(msg_ctx);
+}
+
/****************************************************************************
main program.
****************************************************************************/
@@ -815,6 +839,7 @@ extern void build_options(bool screen);
TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
NTSTATUS status;
uint64_t unique_id;
+ struct rpc_srv_callbacks spoolss_cb;
/* Initialize the event context, it will panic on error */
smbd_event_context();
@@ -1111,6 +1136,26 @@ extern void build_options(bool screen);
return -1;
}
+ /*
+ * Initialize spoolss with an init function to convert printers first.
+ * static_init_rpc will try to initialize the spoolss server too but you
+ * can't register it twice.
+ */
+ spoolss_cb.init = spoolss_init_cb;
+ spoolss_cb.shutdown = NULL;
+ spoolss_cb.private_data = smbd_server_conn->msg_ctx;
+
+ /* Spoolss depends on a winreg pipe, so start it first. */
+ if (!NT_STATUS_IS_OK(rpc_winreg_init(NULL))) {
+ exit(1);
+ }
+
+ if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
+ exit(1);
+ }
+
+ static_init_rpc;
+
/* only start the background queue daemon if we are
running as a daemon -- bad things will happen if
smbd is launched via inetd and we fork a copy of