diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-05-20 19:47:13 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-09-19 09:15:11 +0200 |
commit | e23785ae37bae80d3e356e44a00b21a0037c860e (patch) | |
tree | 6ba9dd2e836270c38b64ef2213b5b0a5874a2003 /source3/smbd/server_exit.c | |
parent | d27ae4a14a1944ea522431a419d45c3036a15eeb (diff) | |
download | samba-e23785ae37bae80d3e356e44a00b21a0037c860e.tar.gz samba-e23785ae37bae80d3e356e44a00b21a0037c860e.tar.xz samba-e23785ae37bae80d3e356e44a00b21a0037c860e.zip |
s3:smbd: introduce 'struct smbXsrv_client' in order to prepare multi-channel support
This structure is supposed to hold the global state shared between
multiple connections from the same client.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/smbd/server_exit.c')
-rw-r--r-- | source3/smbd/server_exit.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c index c708cb65d7..d48a8f283d 100644 --- a/source3/smbd/server_exit.c +++ b/source3/smbd/server_exit.c @@ -85,12 +85,17 @@ static void exit_server_common(enum server_exit_reason how, static void exit_server_common(enum server_exit_reason how, const char *reason) { - struct smbXsrv_connection *xconn = global_smbXsrv_connection; + struct smbXsrv_client *client = global_smbXsrv_client; + struct smbXsrv_connection *xconn = NULL; struct smbd_server_connection *sconn = NULL; struct messaging_context *msg_ctx = server_messaging_context(); - if (xconn != NULL) { - sconn = xconn->sconn; + if (client != NULL) { + sconn = client->sconn; + /* + * Here we typically have just one connection + */ + xconn = client->connections; } if (!exit_firsttime) @@ -99,9 +104,11 @@ static void exit_server_common(enum server_exit_reason how, change_to_root_user(); - if (sconn) { - NTSTATUS status; - + if (xconn != NULL) { + /* + * This is typically the disconnect for the only + * (or with multi-channel last) connection of the client + */ if (NT_STATUS_IS_OK(xconn->transport.status)) { switch (how) { case SERVER_EXIT_ABNORMAL: @@ -114,11 +121,21 @@ static void exit_server_common(enum server_exit_reason how, } TALLOC_FREE(xconn->smb1.negprot.auth_context); + } + + change_to_root_user(); + if (sconn != NULL) { if (lp_log_writeable_files_on_exit()) { bool found = false; files_forall(sconn, log_writeable_file_fn, &found); } + } + + change_to_root_user(); + + if (xconn != NULL) { + NTSTATUS status; /* * Note: this is a no-op for smb2 as @@ -145,10 +162,10 @@ static void exit_server_common(enum server_exit_reason how, how = SERVER_EXIT_ABNORMAL; reason = "smbXsrv_session_logoff_all failed"; } - - change_to_root_user(); } + change_to_root_user(); + /* 3 second timeout. */ print_notify_send_messages(msg_ctx, 3); @@ -200,9 +217,17 @@ static void exit_server_common(enum server_exit_reason how, * we need to force the order of freeing the following, * because smbd_msg_ctx is not a talloc child of smbd_server_conn. */ + if (client != NULL) { + for (; xconn != NULL; xconn = xconn->next) { + DLIST_REMOVE(client->connections, xconn); + talloc_free(xconn); + } + TALLOC_FREE(client->sconn); + } sconn = NULL; xconn = NULL; - TALLOC_FREE(global_smbXsrv_connection); + client = NULL; + TALLOC_FREE(global_smbXsrv_client); server_messaging_context_free(); server_event_context_free(); TALLOC_FREE(smbd_memcache_ctx); |