ifupdown: make the locking errors more useful
This commit is contained in:
parent
0ca8e42ee6
commit
c71c01862d
1 changed files with 9 additions and 3 deletions
|
@ -109,14 +109,14 @@ acquire_state_lock(const char *state_path, const char *lifname)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (exec_opts.verbose)
|
if (exec_opts.verbose)
|
||||||
fprintf(stderr, "ifupdown: acquiring lock on %s\n", lockpath);
|
fprintf(stderr, "%s: acquiring lock on %s\n", argv0, lockpath);
|
||||||
|
|
||||||
if (fcntl(fd, F_SETLKW, &fl) == -1)
|
if (fcntl(fd, F_SETLK, &fl) == -1)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
fprintf(stderr, "locking lockfile: %s\n", strerror(errno));
|
fprintf(stderr, "locking lockfile: %s\n", strerror(errno));
|
||||||
return -1;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
|
@ -127,6 +127,12 @@ change_interface(struct lif_interface *iface, struct lif_dict *collection, struc
|
||||||
{
|
{
|
||||||
int lockfd = acquire_state_lock(exec_opts.state_file, ifname);
|
int lockfd = acquire_state_lock(exec_opts.state_file, ifname);
|
||||||
|
|
||||||
|
if (lockfd == -2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: could not acquire exclusive lock for %s\n", argv0, ifname);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (exec_opts.verbose)
|
if (exec_opts.verbose)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: changing state of interface %s to '%s'\n",
|
fprintf(stderr, "%s: changing state of interface %s to '%s'\n",
|
||||||
|
|
Loading…
Reference in a new issue