summaryrefslogtreecommitdiff
path: root/source4/libcli/composite
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-24 00:57:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:09 -0500
commit3e44c4a3ba6acd7d9bc997c012d1863377e9d873 (patch)
tree3d5dc90c700fa4e10f563f318368efd0df85e8c2 /source4/libcli/composite
parent46b5a3d7542b5e0960e6ef3ac9cbd7fcf142ac3f (diff)
downloadsamba-3e44c4a3ba6acd7d9bc997c012d1863377e9d873.tar.gz
samba-3e44c4a3ba6acd7d9bc997c012d1863377e9d873.tar.bz2
samba-3e44c4a3ba6acd7d9bc997c012d1863377e9d873.zip
r4951: some of the code dealing with libcli was getting too complex trying to
handle the inverted memory hierarchy that a normal session establishment gave. The inverted hierarchy came from that fact that you first establish a socket, then a transport, then a session and finally a tree. That leads to the socket being at the top of the memory hierarchy and the tree at the bottom, which makes no sense from the users point of view, as they want to be able to free the tree and have everything disappear. The core problem was that the libcli interface didn't distinguish between establishing a primary context and a secondary context. If you establish a 2nd session on a transport then you want the transport to be referenced by the session, whereas if you establish a primary session then you want the transport to be a child of the session. To fix this I have added "parent_ctx" and "primary" arguments to the libcli intialisation functions. This makes using the library much easier, and gives us a memory hierarchy that makes much more sense. I was prompted to do this by a bug in the cifs backend, which was caused by the socket not being properly torn down on a disconnect due to the inverted memory hierarchy. (This used to be commit 5e8fd5f70178992e249805c2e1ddafaf6840739b)
Diffstat (limited to 'source4/libcli/composite')
-rw-r--r--source4/libcli/composite/connect.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c
index 69b394310e..8dd7fe39ab 100644
--- a/source4/libcli/composite/connect.c
+++ b/source4/libcli/composite/connect.c
@@ -112,7 +112,7 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c,
state->session->vuid = state->io_setup->out.vuid;
/* setup for a tconx */
- io->out.tree = smbcli_tree_init(state->session);
+ io->out.tree = smbcli_tree_init(state->session, state, True);
NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
state->io_tcon = talloc(c, union smb_tcon);
@@ -157,12 +157,9 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
NT_STATUS_NOT_OK_RETURN(status);
/* next step is a session setup */
- state->session = smbcli_session_init(state->transport);
+ state->session = smbcli_session_init(state->transport, state, True);
NT_STATUS_HAVE_NO_MEMORY(state->session);
- /* get rid of the extra reference to the transport */
- talloc_free(state->transport);
-
state->io_setup = talloc(c, struct smb_composite_sesssetup);
NT_STATUS_HAVE_NO_MEMORY(state->io_setup);
@@ -214,7 +211,7 @@ static NTSTATUS connect_socket(struct smbcli_composite *c,
NT_STATUS_NOT_OK_RETURN(status);
/* the socket is up - we can initialise the smbcli transport layer */
- state->transport = smbcli_transport_init(state->sock);
+ state->transport = smbcli_transport_init(state->sock, state, True);
NT_STATUS_HAVE_NO_MEMORY(state->transport);
calling.name = io->in.calling_name;