Help! Semaphores in Netware 3.11
>I use CATools III to find out how many times my Clipper 5.2e program was
>started in Netware 3.11. Namely, I use
>nHandle := NNetSemOpn("myprog.exe")
>to create or open the semaphore, then
>to find out how many times my program was started.
>Everything is OK but from time to time the semaphore seems to be opened
>although there is no more myprog.exe applications in Netware. So,
>NNetSemOpC() returns 2, although there is only one application active.
>How to solve that problem? Or, how it can be resolved without the use of
>NNetSemOpn()? I should add that in the end I compare NNetSemOpC() return
>value with the value which I save on the disk to check out if every
>application was finished properly (every time the new user starts the
>application it increments the counter and writes it on the disk; when the
>application ends, it decrements the counter and saves it too).
Why not do something like:
nCurrentSemValue := NNetSemVal(nHandle)
nValueToBe := nCurrentSemValue - 1
Do while nValueToBe <> nCurrentSemValue
NNetSemWai(nHandle) // decrement Netware semaphore
nCurrentSemValue := NNetSemVal(nHandle) // get value
This *should* ensure that the semaphore is really getting decremented. There
is one gotcha with Netware semaphores however. If a workstation crashes and
you do not have watchdog timers enabled on the server, the semaphore will hang
around until the workstation reboots. This might explain why you have
"phantom" semaphores when you're sure you shouldn't. Actually, its too bad
your using 3.11, versions prior to 3.11 used to allow a user to actually see
what semaphores were opened by what users (I think it was done with the
fconsole.exe program). Novell saw this as a security breach and removed it as
of 3.11. I've allways wondered if you got an old copy of fconsole whether it
would work on a 3.11 or 3.12 server..... I suppose I could dig through my old
netware distribution disks and find out. It would be an easy way for you to
figure out which workstation has the culprit semaphore.
** Remove ".nospam" when replying or email will bounce back to you...