Thread View: comp.sys.sun
1 messages
1 total messages
Started by David Beckemeyer
Thu, 27 Jun 1991 20:22
Sun NFS file locking
Author: David Beckemeyer
Date: Thu, 27 Jun 1991 20:22
Date: Thu, 27 Jun 1991 20:22
31 lines
1782 bytes
1782 bytes
I have a network application which must be able to obtain exclusive
access to a file. Following the Sun manuals, I'm using hte fcntl()
system call, as follows:
/* Use fcntl to lock the master control file */
sprintf(tmpnam, "%s/LOCKCTL", dir);
lckfd = open(tmpnam, 2);
if (lckfd < 0)
return(seterror("mklock: cannot open LOCKCTL"));
/* lock the whole file for exclusive use */
lck.l_type = F_WRLCK;
lck.l_whence = 0;
lck.l_start = 0;
lck.l_len = 0;
if (fcntl(lckfd, F_SETLK, &lck)) {
close(lckfd);
return(seterror("mklock: F_SETLK failed"));
}
The problems are that sometimes a process will hang in the
fcntl() call; ps reports that the process is in the D state
and the WCHAN is "socket". What is going on? It seems
like the rcp.lockd process gets confused under certain
circumstances. What makes this happen and how does one
avoid it? Is there a reliable way to lock files over the
network with SunOS?
--
David Beckemeyer (david@bdt.COM) | "Lester Moore - Four slugs from a .44
Beckemeyer Development Tools | no Les, no more."
P.O. Box 21575, Oakland, CA 94620 | - Headstone at Boot Hill
UUCP: {uunet,ucbvax}!unisoft!bdt!david | Tombstone, AZ
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads