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.
This commit is contained in:
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -94,7 +94,8 @@ BContext::_Initialize()
|
|||||||
if ((result = tempDirectory.InitCheck()) != B_OK)
|
if ((result = tempDirectory.InitCheck()) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
BString contextName = BString("pkgkit-context-") << find_thread(NULL);
|
BString contextName = BString("pkgkit-context-") << find_thread(NULL)
|
||||||
|
<< "-" << system_time();
|
||||||
BDirectory baseDirectory;
|
BDirectory baseDirectory;
|
||||||
result = tempDirectory.CreateDirectory(contextName.String(),
|
result = tempDirectory.CreateDirectory(contextName.String(),
|
||||||
&baseDirectory);
|
&baseDirectory);
|
||||||
|
|||||||
Reference in New Issue
Block a user