summaryrefslogtreecommitdiffstats
path: root/usr.bin/lockf/lockf.c
Commit message (Collapse)AuthorAgeFilesLines
* Lockf was exiting with status 1 if the command did not exit normally.dwmalone2008-08-211-1/+1
| | | | | | | This is easy to confuse with the actual exit status of the program. Instead exit with EX_SOFTWARE if the command doesn't exit normally. MFC after: 1 month
* Revision 1.12 of lockf.c fixed a "thundering herd" scenario when thecsjp2007-10-121-10/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | lock experienced contention a number of processes would race to acquire lock when it was released. This problem resulted in a lot of CPU load as well as locks being picked up out of order. Unfortunately, a regression snuck in which allowed multiple threads to pickup the same lock when -k was not used. This could occur when multiple processes open a file descriptor to inode X (one process will be blocked) and the file is unlinked on unlock (thereby removing the directory entry allow another process to create a new directory entry for the same file name and lock it). This changes restores the old algorithm of: wait for the lock, then acquire lock when we want to unlink the file on exit (specifically when -k is not used) and keeps the new algorithm for when -k is used, which yields fairness and improved performance. Also, update the man page to inform users that if lockf(1) is being used to facilitate concurrency between a number of processes, it is recommended that -k be used to reduce CPU load and yeld fairness with regard to lock ordering. Collaborated with: jdp PR: bin/114341 PR: bin/116543 PR: bin/111101 MFC after: 1 week
* Finish off style(9) fixes which I started two revisions ago. This basicallycsjp2005-10-091-20/+24
| | | | | changes the indentation style from 4 spaces to 8 spaces which we expect to see in other FreeBSD source files.
* Do not ignore ENOENTcsjp2005-10-071-88/+68
| | | | Pointed out by: Amir Shalem
* Un-break handling of -t 0 which was broken in my previous commit.csjp2005-10-051-5/+6
| | | | | | | | Add a flags argument to wait_for_lock so that O_NONBLOCK can be passed to open if a user doesn't want the open to sleep until the lock becomes available. Submitted by: Amir Shalem (partially modified)
* Fix long standing race condition associated with how lockf uses open(2)csjp2005-10-051-30/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | for mutual exclusion: A brief description of the problem: 1) Proc A picks up non-blocking lock on file X 2) Proc B attempts to pickup lock, fails then waits 3) Proc C attempts to pickup lock, fails then waits 4) Proc A releases lock 5) Proc B acquires lock, release it to pickup a non-blocking version 6) Proc C acquires lock, release it to pickup a non-blocking version 7) Both process B and C race each other to pickup lock again This occurs mainly because the processes do not keep the lock after they have been waiting on it. They drop it, attempt to re-acquire it. (They use the wait to notify when the lock has become available then race to pick it up). This results in additional CPU utilization during the race, and can also result in processes picking locks up out of order. This change attempts to correct this problem by eliminating the test/acquire race and having the operating system handle it. Reported by: kris Tested by: kris MFC after: 1 week
* Use warn() instead of perror().tjr2004-07-151-1/+1
|
* Consistently use FBSDIDobrien2002-06-301-2/+3
|
* Warns cleanups.dwmalone2001-12-031-1/+1
|
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Add a "-k" option, to specify that the lock file should be keptjdp1998-07-081-6/+15
| | | | | | rather than removed. Submitted by: Nick Barnes <Nick.Barnes@pobox.com>
* lockf: usage : lockf -> usage: lockf by using fprintf instead of errx.charnier1997-07-221-2/+4
|
* compare return value from getopt against -1 rather than EOF, per the finalimp1997-03-291-2/+2
| | | | posix standard on the topic.
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* On failure, return various exit codes from <sysexits.h>. In particular,jdp1997-01-091-13/+13
| | | | | | | | | | return EX_TEMPFAIL if the file was already locked. This makes it easier to distinguish between lock collisions and failures within the command being executed. Also, don't complain if the unlink() fails in the cleanup handler. It doesn't matter anyway, and it obscured the exit status returned from the command that was executed.
* Initial import of the lockf utility. It executes an arbitrary commandjdp1997-01-081-0/+213
while holding an exclusive lock on a file.
OpenPOWER on IntegriCloud