summaryrefslogtreecommitdiff
path: root/source4/libcli/raw/clitree.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-26 11:30:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:18 -0500
commite3880fa759cfa03222262327854fe7bbe585fe01 (patch)
tree7000172fad1b5cdcc0d071698ee3e203e61a8f4f /source4/libcli/raw/clitree.c
parentad053090b817105a0974f4b8bf0b90e002297903 (diff)
downloadsamba-e3880fa759cfa03222262327854fe7bbe585fe01.tar.gz
samba-e3880fa759cfa03222262327854fe7bbe585fe01.tar.bz2
samba-e3880fa759cfa03222262327854fe7bbe585fe01.zip
r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count()
rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8)
Diffstat (limited to 'source4/libcli/raw/clitree.c')
-rw-r--r--source4/libcli/raw/clitree.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index e3a1a6d341..e0072a31b1 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -26,6 +26,15 @@
if (!req) return NULL; \
} while (0)
+/*
+ destroy a smbcli_tree
+*/
+static int tree_destructor(void *ptr)
+{
+ struct smbcli_tree *tree = ptr;
+ talloc_free(tree->session);
+ return 0;
+}
/****************************************************************************
Initialize the tree context
@@ -41,25 +50,12 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session)
ZERO_STRUCTP(tree);
tree->session = session;
- tree->session->reference_count++;
+ talloc_set_destructor(tree, tree_destructor);
return tree;
}
/****************************************************************************
-reduce reference count on a tree and destroy if <= 0
-****************************************************************************/
-void smbcli_tree_close(struct smbcli_tree *tree)
-{
- if (!tree) return;
- tree->reference_count--;
- if (tree->reference_count <= 0) {
- smbcli_session_close(tree->session);
- }
-}
-
-
-/****************************************************************************
Send a tconX (async send)
****************************************************************************/
struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms)
@@ -202,7 +198,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
transport = smbcli_transport_init(sock);
if (!transport) {
- smbcli_sock_close(sock);
+ talloc_free(sock);
return NT_STATUS_NO_MEMORY;
}
@@ -211,7 +207,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
choose_called_name(&called, dest_host, 0x20);
if (!smbcli_transport_connect(transport, &calling, &called)) {
- smbcli_transport_close(transport);
+ talloc_free(transport);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -219,13 +215,13 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
/* negotiate protocol options with the server */
status = smb_raw_negotiate(transport);
if (!NT_STATUS_IS_OK(status)) {
- smbcli_transport_close(transport);
+ talloc_free(transport);
return status;
}
session = smbcli_session_init(transport);
if (!session) {
- smbcli_transport_close(transport);
+ talloc_free(transport);
return NT_STATUS_NO_MEMORY;
}
@@ -251,7 +247,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
status = smb_raw_session_setup(session, mem_ctx, &setup);
if (!NT_STATUS_IS_OK(status)) {
- smbcli_session_close(session);
+ talloc_free(session);
talloc_free(mem_ctx);
return status;
}
@@ -260,7 +256,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
tree = smbcli_tree_init(session);
if (!tree) {
- smbcli_session_close(session);
+ talloc_free(session);
talloc_free(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
@@ -284,7 +280,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
SAFE_FREE(in_path);
if (!NT_STATUS_IS_OK(status)) {
- smbcli_tree_close(tree);
+ talloc_free(tree);
talloc_free(mem_ctx);
return status;
}