From 55d4d36993293fee914a009f1d8f05810e347f2b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Jan 2005 00:54:57 +0000 Subject: r5102: This is a major simplification of the logic for controlling top level servers in smbd. The old code still contained a fairly bit of legacy from the time when smbd was only handling SMB connection. The new code gets rid of all of the smb_server specific code in smbd/, and creates a much simpler infrastructures for new server code. Major changes include: - simplified the process model code a lot. - got rid of the top level server and service structures completely. The top level context is now the event_context. This got rid of service.h and server.h completely (they were the most confusing parts of the old code) - added service_stream.[ch] for the helper functions that are specific to stream type services (services that handle streams, and use a logically separate process per connection) - got rid of the builtin idle_handler code in the service logic, as none of the servers were using it, and it can easily be handled by a server in future by adding its own timed_event to the event context. - fixed some major memory leaks in the rpc server code. - added registration of servers, rather than hard coding our list of possible servers. This allows for servers as modules in the future. - temporarily disabled the winbind code until I add the helper functions for that type of server - added error checking on service startup. If a configured server fails to startup then smbd doesn't startup. - cleaned up the command line handling in smbd, removing unused options (This used to be commit cf6a46c3cbde7b1eb1b86bd3882b953a2de3a42e) --- source4/ntvfs/cifs/vfs_cifs.c | 18 +----------------- source4/ntvfs/common/brlock.c | 6 +++--- source4/ntvfs/common/opendb.c | 6 +++--- source4/ntvfs/ipc/vfs_ipc.c | 7 +------ source4/ntvfs/posix/pvfs_wait.c | 5 +++-- source4/ntvfs/posix/vfs_posix.c | 9 +++++---- 6 files changed, 16 insertions(+), 35 deletions(-) (limited to 'source4/ntvfs') diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 7ac687dd46..13b11d8ba2 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -30,6 +30,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" #include "smb_server/smb_server.h" +#include "smbd/service_stream.h" /* this is stored in ntvfs_private */ struct cvfs_private { @@ -48,22 +49,6 @@ struct async_info { #define SETUP_PID private->tree->session->pid = SVAL(req->in.hdr, HDR_PID) -/* - an idle function to cope with messages from the smbd client while - waiting for a reply from the server - this function won't be needed once all of the cifs backend - and the core of smbd is converted to use async calls -*/ -static void idle_func(struct smbcli_transport *transport, void *p_private) -{ - struct cvfs_private *private = p_private; - int fd = socket_get_fd(private->tcon->smb_conn->connection->socket); - - if (socket_pending(fd)) { - smbd_process_async(private->tcon->smb_conn); - } -} - /* a handler for oplock break events from the server - these need to be passed along to the client @@ -158,7 +143,6 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, /* we need to receive oplock break requests from the server */ smbcli_oplock_handler(private->transport, oplock_handler, private); - smbcli_transport_idle_handler(private->transport, idle_func, 50000, private); private->transport->socket->event.fde->handler = cifs_socket_handler; private->transport->socket->event.fde->private = private; diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c index f51e3d0694..d521dc80d3 100644 --- a/source4/ntvfs/common/brlock.c +++ b/source4/ntvfs/common/brlock.c @@ -41,7 +41,7 @@ lock is the same as another lock */ struct lock_context { - servid_t server; + uint32_t server; uint16_t smbpid; uint16_t tid; }; @@ -60,7 +60,7 @@ struct lock_struct { struct brl_context { struct tdb_wrap *w; - servid_t server; + uint32_t server; uint16_t tid; struct messaging_context *messaging_ctx; struct lock_struct last_lock; @@ -72,7 +72,7 @@ struct brl_context { talloc_free(). We need the messaging_ctx to allow for pending lock notifications. */ -struct brl_context *brl_init(TALLOC_CTX *mem_ctx, servid_t server, uint16_t tid, +struct brl_context *brl_init(TALLOC_CTX *mem_ctx, uint32_t server, uint16_t tid, struct messaging_context *messaging_ctx) { char *path; diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index 0aa257073d..3c206528dd 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -44,7 +44,7 @@ struct odb_context { struct tdb_wrap *w; - servid_t server; + uint32_t server; struct messaging_context *messaging_ctx; }; @@ -53,7 +53,7 @@ struct odb_context { following form */ struct odb_entry { - servid_t server; + uint32_t server; void *file_handle; uint32_t stream_id; uint32_t share_access; @@ -78,7 +78,7 @@ struct odb_lock { talloc_free(). We need the messaging_ctx to allow for pending open notifications. */ -struct odb_context *odb_init(TALLOC_CTX *mem_ctx, servid_t server, +struct odb_context *odb_init(TALLOC_CTX *mem_ctx, uint32_t server, struct messaging_context *messaging_ctx) { char *path; diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 402d1ead64..04a1a06db3 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -180,7 +180,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, struct dcerpc_binding ep_description; struct ipc_private *private = ntvfs->private_data; int fnum; - struct server_connection *srv_conn; + struct stream_connection *srv_conn = req->smb_conn->connection; if (!req->session || !req->session->session_info) { return NT_STATUS_ACCESS_DENIED; @@ -211,11 +211,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, ep_description.transport = NCACN_NP; ep_description.endpoint = p->pipe_name; - /* TOTO: pass in full server_connection in here */ - srv_conn = talloc_zero(p, struct server_connection); - NT_STATUS_HAVE_NO_MEMORY(srv_conn); - srv_conn->event.ctx = talloc_reference(srv_conn, req->smb_conn->connection->event.ctx); - /* The session info is refcount-increased in the * dcesrv_endpoint_search_connect() function */ diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index c8d696f0fc..276b1d4e9a 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -24,6 +24,7 @@ #include "events.h" #include "dlinklist.h" #include "vfs_posix.h" +#include "smbd/service_stream.h" /* the context for a single wait instance */ struct pvfs_wait { @@ -56,7 +57,7 @@ NTSTATUS pvfs_async_setup(struct ntvfs_module_context *ntvfs, receive a completion message for a wait */ static void pvfs_wait_dispatch(struct messaging_context *msg, void *private, uint32_t msg_type, - servid_t src, DATA_BLOB *data) + uint32_t src, DATA_BLOB *data) { struct pvfs_wait *pwait = private; struct smbsrv_request *req; @@ -133,7 +134,7 @@ static int pvfs_wait_destructor(void *ptr) pwait->private = private; pwait->handler = fn; - pwait->msg_ctx = pvfs->tcon->smb_conn->connection->messaging.ctx; + pwait->msg_ctx = pvfs->tcon->smb_conn->connection->msg_ctx; pwait->ev = req->tcon->smb_conn->connection->event.ctx; pwait->msg_type = msg_type; pwait->req = talloc_reference(pwait, req); diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 314f9736a3..0ed878c1f0 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -27,6 +27,7 @@ #include "includes.h" #include "vfs_posix.h" #include "librpc/gen_ndr/ndr_security.h" +#include "smbd/service_stream.h" /* @@ -130,16 +131,16 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, ntvfs->private_data = pvfs; pvfs->brl_context = brl_init(pvfs, - pvfs->tcon->smb_conn->connection->connection.id, + pvfs->tcon->smb_conn->connection->server_id, pvfs->tcon->service, - pvfs->tcon->smb_conn->connection->messaging.ctx); + pvfs->tcon->smb_conn->connection->msg_ctx); if (pvfs->brl_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } pvfs->odb_context = odb_init(pvfs, - pvfs->tcon->smb_conn->connection->connection.id, - pvfs->tcon->smb_conn->connection->messaging.ctx); + pvfs->tcon->smb_conn->connection->server_id, + pvfs->tcon->smb_conn->connection->msg_ctx); if (pvfs->odb_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } -- cgit