Fixed the pipe creation and made it secure against very fast threads, as

suggested by Ingo.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3704 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2003-06-28 02:44:20 +00:00
parent f0df28e20e
commit 1792510380

View File

@ -14,10 +14,11 @@
int
pipe(int streams[2])
{
// ToDo: if the thread manages to call this function during the
// the same microsecond twice, we're doomed :)
static int32 counter = 0;
// ToDo: a way without this variable would be even cooler
char pipeName[64];
sprintf(pipeName, "/pipe/%lx-%Ld\n", find_thread(NULL), system_time());
sprintf(pipeName, "/pipe/%03lx-%03ld", find_thread(NULL), atomic_add(&counter, 1));
streams[0] = open(pipeName, O_CREAT | O_RDONLY, 0777);
if (streams[0] < 0)