Operating System - HP-UX
1825761 Members
2152 Online
109687 Solutions
New Discussion

fcntl() fail ENOLCK , how to locate the error??

 
shixinli
New Member

fcntl() fail ENOLCK , how to locate the error??

when our programs execute , fcntl() fails , the error is ENOLCK .I know it means system locktable is full , but I think our programs free all locks .In order to sure whether our programs always lock but miss some free, I want to know how to spy on the system locktable , how can I know how many locks is idle at the current time?

The lock function is as following:
OMERROR OmFileLock(int i_fd)
{
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;

char buf[200];

if(fcntl(i_fd,F_SETLKW,&lock) == -1)
exit(0);
return OM_SUCCESS
}
OMERROR OmFileUnlock(int i_fd)
{
struct flock lock;
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
fcntl(i_fd,F_SETLK,&lock);
return OM_SUCCESS;;
}
calling as following:
OmFileLock()

......(no exit)

OmUnFileLock();

Is there any errors ? Or can you tell me some methods to locate the error.

Now I am very troubled , thank you for you consideration and help !!!
little_eight
2 REPLIES 2
Bruce Laughlin
Frequent Advisor

Re: fcntl() fail ENOLCK , how to locate the error??

Hi shixinli,

I'm pretty sure there are programatic methods that would enable monitoring the system lock table, but I don't know how to do it. I usually just use Glance, and go into system tables, where the number of file locks is displayed.

Looking at the fcntl(2) manpage, I see that ENOLCK can be returned not only because of the lock table being full, but also because of NFS-related issues, so check to see if the object you're tyring to lock is in an NFS-mounted filesystem.

You could also try simply doubling the kernel parameter nflocks and see if that helps.

Best regards,
Bruce Laughlin
HPUX GSE
Kent Ostby
Honored Contributor

Re: fcntl() fail ENOLCK , how to locate the error??


I agree with Bruce that if its across NFS then you may want to check it with a local file first just to eliminate one factor.

You may wish to check the return status of the command: fcntl(i_fd,F_SETLK,&lock) in your Unlock routine to see if that is working correctly (you dont appear to check it in the code above).

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"