From 93cb796e370b6a3e84dc31dba43c24b0e72a94a0 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 18 Sep 2013 15:22:53 +0200 Subject: [PATCH] Context: Add more uniqueness to temp directory names. - If a single thread attempted to establish multiple package kit contexts, it would fail due to a collision between their respective temporary directories. As such, use both the thread ID and system_time() as a random elements in the directory name to ensure this doesn't occur. --- src/kits/package/Context.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kits/package/Context.cpp b/src/kits/package/Context.cpp index eec15b3412..7ed7d146ff 100644 --- a/src/kits/package/Context.cpp +++ b/src/kits/package/Context.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011, Haiku, Inc. All Rights Reserved. + * Copyright 2011-2013, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -94,7 +94,8 @@ BContext::_Initialize() if ((result = tempDirectory.InitCheck()) != B_OK) return result; - BString contextName = BString("pkgkit-context-") << find_thread(NULL); + BString contextName = BString("pkgkit-context-") << find_thread(NULL) + << "-" << system_time(); BDirectory baseDirectory; result = tempDirectory.CreateDirectory(contextName.String(), &baseDirectory);