From 09d0b152b7bd85aa01898af81bd166a7673ab886 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 29 Oct 2004 08:38:59 +0000 Subject: r3360: improved the deletion of tmp files. smbd now puts all tmp files in var/locks/smbd.tmp/ and deletes that dir on startup. (This used to be commit 7e942e7f1bd2c293a0e6648df43a96f8b8a2a295) --- source4/libcli/unexpected.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source4/libcli/unexpected.c') diff --git a/source4/libcli/unexpected.c b/source4/libcli/unexpected.c index 19a02bdeb8..264b9d7b33 100644 --- a/source4/libcli/unexpected.c +++ b/source4/libcli/unexpected.c @@ -44,15 +44,13 @@ void unexpected_packet(struct packet_struct *p) struct unexpected_key key; char buf[1024]; int len=0; - TALLOC_CTX *mem_ctx; if (!tdbd) { - mem_ctx = talloc_init("receive_unexpected"); - if (!mem_ctx) return; - tdbd = tdb_wrap_open(NULL, lock_path(mem_ctx, "unexpected.tdb"), 0, + char *path = smbd_tmp_path(NULL, "unexpected.tdb"); + tdbd = tdb_wrap_open(NULL, path, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644); - talloc_destroy(mem_ctx); + talloc_free(path); if (!tdbd) { return; } @@ -150,13 +148,12 @@ struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, const char *mailslot_name) { struct tdb_wrap *tdb2; - TALLOC_CTX *mem_ctx; + char *path; - mem_ctx = talloc_init("receive_unexpected"); - if (!mem_ctx) return NULL; - tdb2 = tdb_wrap_open(mem_ctx, lock_path(mem_ctx, "unexpected.tdb"), 0, 0, O_RDONLY, 0); + path = smbd_tmp_path(NULL, "unexpected.tdb"); + tdb2 = tdb_wrap_open(NULL, path, 0, 0, O_RDONLY, 0); + talloc_free(path); if (!tdb2) { - talloc_destroy(mem_ctx); return NULL; } @@ -167,7 +164,7 @@ struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, tdb_traverse(tdb2->tdb, traverse_match, NULL); - talloc_destroy(mem_ctx); + talloc_free(tdb2); return matched_packet; } -- cgit