The branch, master has been updated via 8faee7b s3-rpc_server: Pass event and messaging context to accept function. via c69f2c4 s3-librpc: Pass messaging context to dcerpc register functions. via 8b085c0 s3-smbd: Pass event and messaging context to smbd_parent_housekeeping(). via 68520ec s3-smbd: Pass ev_ctx to remove_child_pid(). via 7da54ea s3-smbd: Pass msg_ctx to smbd_accept_connection. via fa1bba2 s3-smbd: Pass ev_ctx to smbd_setup_sig_chld_handler(). via 55a025e s3-smbd: Pass ev_ctx and msg_ctx to smbd_accept_connection(). via 0b8f8f1 s3-smbd: Pass ev_ctx and msg_ctx to open_sockets_smbd(). via a3dc8f7 s3-smbd: Pass ev_ctx to smbd_parent_loop(). via 4c446c0 s3-smbd: Create ev_ctx and msg_ctx and use it. from 39af6a0 s4-winbind handle all values for server role
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 8faee7bd9b20b389f5ae996baec849d45afc0024 Author: Andreas Schneider <a...@samba.org> Date: Fri Jul 8 11:38:03 2011 +0200 s3-rpc_server: Pass event and messaging context to accept function. Autobuild-User: Andreas Schneider <a...@cryptomilk.org> Autobuild-Date: Thu Jul 14 17:22:16 CEST 2011 on sn-devel-104 commit c69f2c4de992104e83a6e945835c47e5b919c04d Author: Andreas Schneider <a...@samba.org> Date: Fri Jul 8 11:34:24 2011 +0200 s3-librpc: Pass messaging context to dcerpc register functions. commit 8b085c02eba4beeb38c1d4ca9635e830a7658ea8 Author: Andreas Schneider <a...@samba.org> Date: Fri Jul 8 11:28:12 2011 +0200 s3-smbd: Pass event and messaging context to smbd_parent_housekeeping(). commit 68520ec02cafde1f38e8630b67292d921ce30f34 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 14:46:16 2011 +0200 s3-smbd: Pass ev_ctx to remove_child_pid(). commit 7da54eab641a0b9fa2aca63cbf3364cb34efb812 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 14:45:45 2011 +0200 s3-smbd: Pass msg_ctx to smbd_accept_connection. commit fa1bba26aae83b5412601e102f65a58ec7a146e4 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 14:24:03 2011 +0200 s3-smbd: Pass ev_ctx to smbd_setup_sig_chld_handler(). commit 55a025e0410e8105af42838ba2a4b8a7933d6dd0 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 14:14:18 2011 +0200 s3-smbd: Pass ev_ctx and msg_ctx to smbd_accept_connection(). commit 0b8f8f18fb24bf3f8521e85039762228e7027293 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 14:11:51 2011 +0200 s3-smbd: Pass ev_ctx and msg_ctx to open_sockets_smbd(). commit a3dc8f71d27bf8e419aaf778dbfbb7faacdf9e74 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 14:07:25 2011 +0200 s3-smbd: Pass ev_ctx to smbd_parent_loop(). commit 4c446c0297560d2f6577a32680ac853868129626 Author: Andreas Schneider <a...@samba.org> Date: Tue Jun 21 13:58:54 2011 +0200 s3-smbd: Create ev_ctx and msg_ctx and use it. ----------------------------------------------------------------------- Summary of changes: source3/librpc/rpc/dcerpc_ep.c | 11 +++- source3/librpc/rpc/dcerpc_ep.h | 5 +- source3/rpc_server/rpc_ep_setup.c | 1 + source3/rpc_server/rpc_server.c | 19 ++++-- source3/smbd/server.c | 139 +++++++++++++++++++++++-------------- 5 files changed, 114 insertions(+), 61 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c index 7341bc4..14d475f 100644 --- a/source3/librpc/rpc/dcerpc_ep.c +++ b/source3/librpc/rpc/dcerpc_ep.c @@ -134,6 +134,7 @@ done: } static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, @@ -187,7 +188,7 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, &ndr_table_epmapper, local, get_session_info_system(), - server_messaging_context(), + msg_ctx, &h); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("dcerpc_ep_register: Could not connect to " @@ -309,6 +310,7 @@ done: } NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, @@ -316,6 +318,7 @@ NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle **ph) { return ep_register(mem_ctx, + msg_ctx, iface, bind_vec, object_guid, @@ -326,6 +329,7 @@ NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, } NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, @@ -333,6 +337,7 @@ NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle **ph) { return ep_register(mem_ctx, + msg_ctx, iface, bind_vec, object_guid, @@ -342,11 +347,13 @@ NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, ph); } -NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface, +NTSTATUS dcerpc_ep_unregister(struct messaging_context *msg_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid) { return ep_register(NULL, + msg_ctx, iface, bind_vec, object_guid, diff --git a/source3/librpc/rpc/dcerpc_ep.h b/source3/librpc/rpc/dcerpc_ep.h index 57b1d27..226d402 100644 --- a/source3/librpc/rpc/dcerpc_ep.h +++ b/source3/librpc/rpc/dcerpc_ep.h @@ -64,6 +64,7 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx, * @return An NTSTATUS error code. */ NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, @@ -71,13 +72,15 @@ NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle **ph); NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, const char *annotation, struct dcerpc_binding_handle **ph); -NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface, +NTSTATUS dcerpc_ep_unregister(struct messaging_context *msg_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid); diff --git a/source3/rpc_server/rpc_ep_setup.c b/source3/rpc_server/rpc_ep_setup.c index 7dc23aa..7f40dda 100644 --- a/source3/rpc_server/rpc_ep_setup.c +++ b/source3/rpc_server/rpc_ep_setup.c @@ -271,6 +271,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx, } status = dcerpc_ep_register(mem_ctx, + msg_ctx, iface, v, &iface->syntax_id.uuid, diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index a54ade4..2dffaff 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -282,7 +282,10 @@ out: return false; } -static void named_pipe_accept_function(const char *pipe_name, int fd); +static void named_pipe_accept_function(struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + const char *pipe_name, + int fd); static void named_pipe_listener(struct tevent_context *ev, struct tevent_fd *fde, @@ -313,7 +316,10 @@ static void named_pipe_listener(struct tevent_context *ev, DEBUG(6, ("Accepted socket %d\n", sd)); - named_pipe_accept_function(state->ep.name, sd); + named_pipe_accept_function(state->ev_ctx, + state->msg_ctx, + state->ep.name, + sd); } @@ -350,7 +356,10 @@ struct named_pipe_client { static void named_pipe_accept_done(struct tevent_req *subreq); -static void named_pipe_accept_function(const char *pipe_name, int fd) +static void named_pipe_accept_function(struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + const char *pipe_name, + int fd) { struct named_pipe_client *npc; struct tstream_context *plain; @@ -364,8 +373,8 @@ static void named_pipe_accept_function(const char *pipe_name, int fd) return; } npc->pipe_name = pipe_name; - npc->ev = server_event_context(); - npc->msg_ctx = server_messaging_context(); + npc->ev = ev_ctx; + npc->msg_ctx = msg_ctx; /* make sure socket is in NON blocking state */ ret = set_blocking(fd, false); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 3f656ac..6fc2a14 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -237,7 +237,9 @@ static void cleanup_timeout_fn(struct event_context *event_ctx, (*cleanup_te) = NULL; } -static void remove_child_pid(pid_t pid, bool unclean_shutdown) +static void remove_child_pid(struct tevent_context *ev_ctx, + pid_t pid, + bool unclean_shutdown) { struct child_pid *child; static struct timed_event *cleanup_te; @@ -253,7 +255,7 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown) if (!cleanup_te) { /* call the cleanup timer, but not too often */ int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20); - cleanup_te = event_add_timed(server_event_context(), NULL, + cleanup_te = event_add_timed(ev_ctx, NULL, timeval_current_ofs(cleanup_time, 0), cleanup_timeout_fn, &cleanup_te); @@ -323,16 +325,16 @@ static void smbd_sig_chld_handler(struct tevent_context *ev, if (WIFSIGNALED(status)) { unclean_shutdown = True; } - remove_child_pid(pid, unclean_shutdown); + remove_child_pid(ev, pid, unclean_shutdown); } } -static void smbd_setup_sig_chld_handler(void) +static void smbd_setup_sig_chld_handler(struct tevent_context *ev_ctx) { struct tevent_signal *se; - se = tevent_add_signal(server_event_context(), - server_event_context(), + se = tevent_add_signal(ev_ctx, + ev_ctx, /* mem_ctx */ SIGCHLD, 0, smbd_sig_chld_handler, NULL); @@ -355,6 +357,7 @@ struct smbd_open_socket { struct smbd_parent_context *parent; int fd; struct tevent_fd *fde; + struct messaging_context *msg_ctx; }; static void smbd_open_socket_close_fn(struct tevent_context *ev, @@ -374,6 +377,7 @@ static void smbd_accept_connection(struct tevent_context *ev, struct smbd_server_connection *sconn = smbd_server_conn; struct smbd_open_socket *s = talloc_get_type_abort(private_data, struct smbd_open_socket); + struct messaging_context *msg_ctx = s->msg_ctx; struct sockaddr_storage addr; socklen_t in_addrlen = sizeof(addr); int fd; @@ -433,8 +437,9 @@ static void smbd_accept_connection(struct tevent_context *ev, talloc_free(s->parent); s = NULL; - status = reinit_after_fork(smbd_messaging_context(), - server_event_context(), procid_self(), + status = reinit_after_fork(msg_ctx, + ev, + procid_self(), true); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, @@ -457,8 +462,8 @@ static void smbd_accept_connection(struct tevent_context *ev, } smbd_setup_sig_term_handler(); - smbd_setup_sig_hup_handler(server_event_context(), - server_messaging_context()); + smbd_setup_sig_hup_handler(ev, + msg_ctx); if (!serverid_register(procid_self(), FLAG_MSG_GENERAL|FLAG_MSG_SMBD @@ -513,6 +518,8 @@ static void smbd_accept_connection(struct tevent_context *ev, } static bool smbd_open_one_socket(struct smbd_parent_context *parent, + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, const struct sockaddr_storage *ifss, uint16_t port) { @@ -555,7 +562,8 @@ static bool smbd_open_one_socket(struct smbd_parent_context *parent, return false; } - s->fde = tevent_add_fd(server_event_context(), + s->msg_ctx = msg_ctx; + s->fde = tevent_add_fd(ev_ctx, s, s->fd, TEVENT_FD_READ, smbd_accept_connection, @@ -577,6 +585,8 @@ static bool smbd_open_one_socket(struct smbd_parent_context *parent, static bool smbd_parent_housekeeping(const struct timeval *now, void *private_data) { + struct messaging_context *msg_ctx = + talloc_get_type_abort(private_data, struct messaging_context); time_t printcap_cache_time = (time_t)lp_printcap_cache_time(); time_t t = time_mono(NULL); @@ -586,8 +596,8 @@ static bool smbd_parent_housekeeping(const struct timeval *now, void *private_da if ((printcap_cache_time != 0) && (t >= (last_printer_reload_time + printcap_cache_time))) { DEBUG( 3,( "Printcap cache time expired.\n")); - pcap_cache_reload(server_event_context(), - smbd_messaging_context(), + pcap_cache_reload(messaging_event_context(msg_ctx), + msg_ctx, &reload_pcap_change_notify); last_printer_reload_time = t; } @@ -600,6 +610,7 @@ static bool smbd_parent_housekeeping(const struct timeval *now, void *private_da ****************************************************************************/ static bool open_sockets_smbd(struct smbd_parent_context *parent, + struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, const char *smb_ports) { @@ -613,7 +624,7 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, #endif /* Stop zombies */ - smbd_setup_sig_chld_handler(); + smbd_setup_sig_chld_handler(ev_ctx); /* use a reasonable default set of ports - listing on 445 and 139 */ if (!smb_ports) { @@ -662,7 +673,11 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, dns_port = port; } - if (!smbd_open_one_socket(parent, ifss, port)) { + if (!smbd_open_one_socket(parent, + ev_ctx, + msg_ctx, + ifss, + port)) { return false; } } @@ -709,7 +724,11 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, continue; } - if (!smbd_open_one_socket(parent, &ss, port)) { + if (!smbd_open_one_socket(parent, + ev_ctx, + msg_ctx, + &ss, + port)) { return false; } } @@ -736,10 +755,10 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, return false; } - if (!(event_add_idle(server_event_context(), NULL, + if (!(event_add_idle(ev_ctx, NULL, timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0), "parent_housekeeping", smbd_parent_housekeeping, - NULL))) { + msg_ctx))) { DEBUG(0, ("Could not add parent_housekeeping event\n")); return false; } @@ -750,12 +769,12 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, messaging_register(msg_ctx, NULL, MSG_SHUTDOWN, msg_exit_server); messaging_register(msg_ctx, NULL, MSG_SMB_FILE_RENAME, msg_file_was_renamed); - messaging_register(msg_ctx, server_event_context(), MSG_SMB_CONF_UPDATED, + messaging_register(msg_ctx, ev_ctx, MSG_SMB_CONF_UPDATED, smb_conf_updated); messaging_register(msg_ctx, NULL, MSG_SMB_STAT_CACHE_DELETE, smb_stat_cache_delete); messaging_register(msg_ctx, NULL, MSG_DEBUG, smbd_msg_debug); - messaging_register(msg_ctx, server_event_context(), MSG_PRINTER_PCAP, + messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP, smb_pcap_updated); brl_register_msgs(msg_ctx); @@ -774,14 +793,15 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, if (lp_multicast_dns_register() && (dns_port != 0)) { #ifdef WITH_DNSSD_SUPPORT - smbd_setup_mdns_registration(server_event_context(), + smbd_setup_mdns_registration(ev_ctx, parent, dns_port); #endif #ifdef WITH_AVAHI_SUPPORT void *avahi_conn; - avahi_conn = avahi_start_register( - server_event_context(), server_event_context(), dns_port); + avahi_conn = avahi_start_register(ev_ctx, + ev_ctx, + dns_port); if (avahi_conn == NULL) { DEBUG(10, ("avahi_start_register failed\n")); } @@ -791,7 +811,8 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, return true; } -static void smbd_parent_loop(struct smbd_parent_context *parent) +static void smbd_parent_loop(struct tevent_context *ev_ctx, + struct smbd_parent_context *parent) { /* now accept incoming connections - forking a new process for each incoming connection */ @@ -800,7 +821,7 @@ static void smbd_parent_loop(struct smbd_parent_context *parent) int ret; TALLOC_CTX *frame = talloc_stackframe(); - ret = tevent_loop_once(server_event_context()); + ret = tevent_loop_once(ev_ctx); if (ret != 0) { exit_server_cleanly("tevent_loop_once() error"); } @@ -880,6 +901,8 @@ extern void build_options(bool screen); TALLOC_CTX *frame; NTSTATUS status; uint64_t unique_id; + struct tevent_context *ev_ctx; + struct messaging_context *msg_ctx; /* * Do this before any other talloc operation @@ -889,9 +912,6 @@ extern void build_options(bool screen); load_case_tables(); - /* Initialize the event context, it will panic on error */ - server_event_context(); - smbd_init_globals(); TimeInit(); @@ -1029,8 +1049,25 @@ extern void build_options(bool screen); /* Init the security context and global current_user */ init_sec_ctx(); - if (smbd_messaging_context() == NULL) + /* + * Initialize the event context. The event context needs to be + * initialized before the messaging context, cause the messaging + * context holds an event context. + * FIXME: This should be s3_tevent_context_init() + */ + ev_ctx = server_event_context(); + if (ev_ctx == NULL) { exit(1); + } + + /* + * Init the messaging context + * FIXME: This should only call messaging_init() + */ + msg_ctx = server_messaging_context(); + if (msg_ctx == NULL) { + exit(1); + } /* * Reloading of the printers will not work here as we don't have a @@ -1047,7 +1084,7 @@ extern void build_options(bool screen); init_structs(); #ifdef WITH_PROFILE - if (!profile_setup(smbd_messaging_context(), False)) { + if (!profile_setup(msg_ctx, False)) { DEBUG(0,("ERROR: failed to setup profiling\n")); return -1; } @@ -1096,19 +1133,19 @@ extern void build_options(bool screen); if (is_daemon) pidfile_create("smbd"); - status = reinit_after_fork(smbd_messaging_context(), - server_event_context(), + status = reinit_after_fork(msg_ctx, + ev_ctx, procid_self(), false); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } - smbd_server_conn->msg_ctx = smbd_messaging_context(); + smbd_server_conn->msg_ctx = msg_ctx; smbd_setup_sig_term_handler(); - smbd_setup_sig_hup_handler(server_event_context(), - smbd_server_conn->msg_ctx); + smbd_setup_sig_hup_handler(ev_ctx, + msg_ctx); /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */ @@ -1121,7 +1158,7 @@ extern void build_options(bool screen); /* Initialise the password backed before the global_sam_sid to ensure that we fetch from ldap before we make a domain sid up */ - if(!initialize_password_db(False, server_event_context())) + if(!initialize_password_db(false, ev_ctx)) exit(1); if (!secrets_init()) { @@ -1151,15 +1188,15 @@ extern void build_options(bool screen); if (!locking_init()) exit(1); - if (!messaging_tdb_parent_init(server_event_context())) { + if (!messaging_tdb_parent_init(ev_ctx)) { exit(1); } - if (!notify_internal_parent_init(server_event_context())) { + if (!notify_internal_parent_init(ev_ctx)) { exit(1); } - if (!serverid_parent_init(server_event_context())) { + if (!serverid_parent_init(ev_ctx)) { exit(1); } -- Samba Shared Repository