🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1573

My Mutex stupidity - Help please

#1573
From: static array?
Date: Tue, 17 Jul 2007 15:17
23 lines
1608 bytes
I was having issues with my mutex handler - and have boiled it down to this.

What the heck is wrong with this. I expect to create a deadlock here - but 
it doesnt happen!

char * c = "ksfgkjsfdgkj\0";

HANDLE MutexHandle1 = CreateMutex(NULL, FALSE, c);
WaitForSingleObject(MutexHandle1, INFINITE);

// ok so I have the mutex lock now

// lets try to create (open) the same mutex.  (I note that the handle
// address returned is different for each call).

HANDLE MutexHandle2 = CreateMutex(NULL, FALSE, c); // note exact same name
WaitForSingleObject(MutexHandle2, INFINITE);

// I expect that last call to never return - but it does immediately.
// I also note that a call to GetLastError does indeed return 
ALREADY_EXISTS.... so I am confused...

What am I doing wrong here?
Technical Details
Message-ID: <469cdda8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fca5f87658921108,start
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "static array?" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: My Mutex stupidity - Help please
Date: Tue, 17 Jul 2007 08:17:07 -0700
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 207.61.87.125
Message-ID: <469cdda8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1184685480 207.61.87.125 (17 Jul 2007 08:18:00 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail