summaryrefslogtreecommitdiff
path: root/source3/smbd/msdfs.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-11-16 09:49:23 +0100
committerVolker Lendecke <vl@samba.org>2009-11-18 23:16:13 +0100
commitf6650f5d19ad90b8e1f392efbe211c4ffa0e70c0 (patch)
tree6091c37e17a96edaaab867094b99bfe8c5aa456d /source3/smbd/msdfs.c
parentaea3a8f50131744f8393d0179cd04a1b97982028 (diff)
downloadsamba-f6650f5d19ad90b8e1f392efbe211c4ffa0e70c0.tar.gz
samba-f6650f5d19ad90b8e1f392efbe211c4ffa0e70c0.tar.bz2
samba-f6650f5d19ad90b8e1f392efbe211c4ffa0e70c0.zip
s3: Do not talloc in readdir
This is a hot codepath (called from the stat cache)
Diffstat (limited to 'source3/smbd/msdfs.c')
-rw-r--r--source3/smbd/msdfs.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index 4a338fa590..fce8417045 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -1505,7 +1505,8 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
{
size_t cnt = 0;
SMB_STRUCT_DIR *dirp = NULL;
- char *dname = NULL;
+ const char *dname = NULL;
+ char *talloced = NULL;
const char *connect_path = lp_pathname(snum);
const char *msdfs_proxy = lp_msdfs_proxy(snum);
connection_struct *conn;
@@ -1542,13 +1543,14 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
goto out;
}
- while ((dname = vfs_readdirname(conn, dirp, NULL)) != NULL) {
+ while ((dname = vfs_readdirname(conn, dirp, NULL, &talloced))
+ != NULL) {
if (is_msdfs_link(conn,
dname,
NULL)) {
cnt++;
}
- TALLOC_FREE(dname);
+ TALLOC_FREE(talloced);
}
SMB_VFS_CLOSEDIR(conn,dirp);
@@ -1569,7 +1571,8 @@ static int form_junctions(TALLOC_CTX *ctx,
{
size_t cnt = 0;
SMB_STRUCT_DIR *dirp = NULL;
- char *dname = NULL;
+ const char *dname = NULL;
+ char *talloced = NULL;
const char *connect_path = lp_pathname(snum);
char *service_name = lp_servicename(snum);
const char *msdfs_proxy = lp_msdfs_proxy(snum);
@@ -1643,12 +1646,13 @@ static int form_junctions(TALLOC_CTX *ctx,
goto out;
}
- while ((dname = vfs_readdirname(conn, dirp, NULL)) != NULL) {
+ while ((dname = vfs_readdirname(conn, dirp, NULL, &talloced))
+ != NULL) {
char *link_target = NULL;
if (cnt >= jn_remain) {
DEBUG(2, ("form_junctions: ran out of MSDFS "
"junction slots"));
- TALLOC_FREE(dname);
+ TALLOC_FREE(talloced);
goto out;
}
if (is_msdfs_link_internal(ctx,
@@ -1666,7 +1670,7 @@ static int form_junctions(TALLOC_CTX *ctx,
dname);
if (!jucn[cnt].service_name ||
!jucn[cnt].volume_name) {
- TALLOC_FREE(dname);
+ TALLOC_FREE(talloced);
goto out;
}
jucn[cnt].comment = "";
@@ -1674,7 +1678,7 @@ static int form_junctions(TALLOC_CTX *ctx,
}
TALLOC_FREE(link_target);
}
- TALLOC_FREE(dname);
+ TALLOC_FREE(talloced);
}
out: