The Samba-Bugzilla – Attachment 10946 Details for
Bug 11195
Socket leak after calling smbc_free_context() when connected to a DFS target
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Makes use of code from cli_shutdown to ensure that all sockets are closed when calling smbc_free_context for a DFS connection. Note that this patch is merely a demonstration.
samba-4.1.x-libsmb_context_socket_leak.patch (text/plain), 4.11 KB, created by
Chris
on 2015-04-13 13:26:38 UTC
(
hide
)
Description:
Makes use of code from cli_shutdown to ensure that all sockets are closed when calling smbc_free_context for a DFS connection. Note that this patch is merely a demonstration.
Filename:
MIME Type:
Creator:
Chris
Created:
2015-04-13 13:26:38 UTC
Size:
4.11 KB
patch
obsolete
>diff -Npru samba-4.1.12.orig/source3/libsmb/libsmb_context.c samba-4.1.12/source3/libsmb/libsmb_context.c >--- samba-4.1.12.orig/source3/libsmb/libsmb_context.c 2014-07-28 03:13:45.000000000 -0400 >+++ samba-4.1.12/source3/libsmb/libsmb_context.c 2015-04-13 06:34:36.261094454 -0400 >@@ -242,6 +242,9 @@ int > smbc_free_context(SMBCCTX *context, > int shutdown_ctx) > { >+ >+ DEBUG(1, ("Called smbc_free_context...\n")); >+ > TALLOC_CTX *frame; > if (!context) { > errno = EBADF; >@@ -262,25 +265,89 @@ smbc_free_context(SMBCCTX *context, > context->internal->files = NULL; > > /* First try to remove the servers the nice way. */ >- if (smbc_getFunctionPurgeCachedServers(context)(context)) { >+ >+ //Below returns 0 regardless >+ //if (smbc_getFunctionPurgeCachedServers(context)(context)) { > SMBCSRV * s; > SMBCSRV * next; > DEBUG(1, ("Could not purge all servers, " > "Nice way shutdown failed.\n")); > s = context->internal->servers; >+ > while (s) { > DEBUG(1, ("Forced shutdown: %p (cli=%p)\n", > s, s->cli)); >- cli_shutdown(s->cli); >- smbc_getFunctionRemoveCachedServer(context)(context, >- s); >+ //cli_shutdown(s->cli); >+ >+ DEBUG(1,("Calling what would be cli_shutdown\n")); >+ >+ struct cli_state *cli_head; >+ >+ DLIST_HEAD(s->cli, cli_head); >+ //if (cli_head == s->cli) { //These are not equal even if we are using DFS >+ /* >+ * head of a DFS list, shutdown all subsidiary DFS >+ * connections. >+ */ >+ >+ DEBUG(1,("Should be closing DFS connections.\n")); >+ >+ struct cli_state *p, *next; >+ >+ //Prior to altering the below there would still be two sockets left open. >+ //for (p = cli_head->next; p; p = next) { >+ for (p = cli_head; p; p = next) { >+ >+ DEBUG(1,("Closing a DFS connection.\n")); >+ >+ next = p->next; >+ DLIST_REMOVE(cli_head, p); >+ >+ //_cli_shutdown(p); >+ >+ DEBUG(1,("Calling what would be _cli_shutdown\n")); >+ >+ cli_nt_pipes_close(p); >+ >+ if (cli_state_has_tcon(p)) { >+ cli_tdis(p); >+ } >+ >+ smbXcli_conn_disconnect(p->conn, NT_STATUS_OK); >+ >+ TALLOC_FREE(p); >+ >+ DEBUG(1,("Finished calling what would be _cli_shutdown\n")); >+ } >+ /* } else { >+ DLIST_REMOVE(cli_head, s->cli); >+ }*/ >+ >+ //_cli_shutdown(s->cli); >+ >+ DEBUG(1,("Calling what would be _cli_shutdown at the end\n")); >+ >+ cli_nt_pipes_close(s->cli); >+ >+ if (cli_state_has_tcon(s->cli)) { >+ cli_tdis(s->cli); >+ } >+ >+ smbXcli_conn_disconnect(s->cli->conn, NT_STATUS_OK); >+ >+ //TALLOC error if this is not removed >+ //TALLOC_FREE(s->cli); >+ >+ DEBUG(1,("Finished calling what would be _cli_shutdown at the end\n")); >+ >+ smbc_getFunctionRemoveCachedServer(context)(context,s); > next = s->next; > DLIST_REMOVE(context->internal->servers, s); > SAFE_FREE(s); > s = next; > } > context->internal->servers = NULL; >- } >+ //} > } > else { > /* This is the polite way */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 11195
: 10946