lockfile: Remove force parameter from hold_lock()
If user wants to 'force' a lock, he/she will have to remove the file manually. some wierd race conditions may happen if different processes optains the same lock at any given time (thats why lockfile is implemented in the first place) So lockfile API should not in any circumstances directly provide a way to force taking a lock.
This commit is contained in:
parent
c731173b49
commit
697d512ea6
5 changed files with 9 additions and 16 deletions
|
|
@ -300,7 +300,7 @@ static int parse_config_file(const char *file) {
|
|||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int lockfd, force = 0;
|
||||
int lockfd;
|
||||
struct lockfile lock = LOCKFILE_INIT;
|
||||
char filename[4096];
|
||||
|
||||
|
|
@ -319,11 +319,7 @@ int main(int argc, char **argv) {
|
|||
snprintf(filename, sizeof(filename), "%s/%s",
|
||||
env_get_dir(), "config");
|
||||
|
||||
/* Remove lockfile if forced */
|
||||
if (argc > 1 && !strcmp(argv[1], "-f"))
|
||||
force = 1;
|
||||
|
||||
lockfd = hold_lock(&lock, filename, force);
|
||||
lockfd = hold_lock(&lock, filename);
|
||||
if (lockfd < 0)
|
||||
return 1;
|
||||
|
||||
|
|
|
|||
Reference in a new issue