Acked-by: Alex Wang <al...@nicira.com>
On Tue, Mar 25, 2014 at 3:51 PM, Ben Pfaff <b...@nicira.com> wrote: > "Resource deadlock avoided" is a pretty obscure message. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > lib/lockfile.c | 6 +++++- > tests/lockfile.at | 20 ++++++++++---------- > 2 files changed, 15 insertions(+), 11 deletions(-) > > diff --git a/lib/lockfile.c b/lib/lockfile.c > index c83f469..d157bc6 100644 > --- a/lib/lockfile.c > +++ b/lib/lockfile.c > @@ -122,7 +122,10 @@ lockfile_lock(const char *file, struct lockfile > **lockfilep) > if (error == EACCES) { > error = EAGAIN; > } > - if (pid) { > + if (pid == getpid()) { > + VLOG_WARN("%s: cannot lock file because this process has > already " > + "locked it", lock_name); > + } else if (pid) { > VLOG_WARN("%s: cannot lock file because it is already locked > by " > "pid %ld", lock_name, (long int) pid); > } else { > @@ -307,6 +310,7 @@ lockfile_try_lock(const char *name, pid_t *pidp, > struct lockfile **lockfilep) > /* Check whether we've already got a lock on that file. */ > if (!stat(name, &s)) { > if (lockfile_find(s.st_dev, s.st_ino)) { > + *pidp = getpid(); > return EDEADLK; > } > } else if (errno != ENOENT) { > diff --git a/tests/lockfile.at b/tests/lockfile.at > index 2644d3f..d5f2eac 100644 > --- a/tests/lockfile.at > +++ b/tests/lockfile.at > @@ -14,12 +14,12 @@ CHECK_LOCKFILE([lock_and_unlock], [0]) > CHECK_LOCKFILE([lock_and_unlock_twice], [0]) > > CHECK_LOCKFILE([lock_blocks_same_process], [0], > - [lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock > avoided > + [lockfile|WARN|.file.~lock~: cannot lock file because this process has > already locked it > ]) > > CHECK_LOCKFILE([lock_blocks_same_process_twice], [0], > - [lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock > avoided > -lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock avoided > + [lockfile|WARN|.file.~lock~: cannot lock file because this process has > already locked it > +lockfile|WARN|.file.~lock~: cannot lock file because this process has > already locked it > ]) > > CHECK_LOCKFILE([lock_blocks_other_process], [1], > @@ -28,7 +28,7 @@ lockfile|WARN|.file.~lock~: cannot lock file because it > is already locked by pid > ]) > > CHECK_LOCKFILE([lock_twice_blocks_other_process], [1], > - [lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock > avoided > + [lockfile|WARN|.file.~lock~: cannot lock file because this process has > already locked it > lockfile|WARN|.file.~lock~: child does not inherit lock > lockfile|WARN|.file.~lock~: cannot lock file because it is already locked > by pid <pid> > ]) > @@ -36,16 +36,16 @@ lockfile|WARN|.file.~lock~: cannot lock file because > it is already locked by pid > CHECK_LOCKFILE([lock_and_unlock_allows_other_process], [1]) > > CHECK_LOCKFILE([lock_multiple], [0], > - [lockfile|WARN|.a.~lock~: failed to lock file: Resource deadlock avoided > + [lockfile|WARN|.a.~lock~: cannot lock file because this process has > already locked it > ]) > > CHECK_LOCKFILE([lock_symlink], [0], > - [lockfile|WARN|.a.~lock~: failed to lock file: Resource deadlock avoided > -lockfile|WARN|.b.~lock~: failed to lock file: Resource deadlock avoided > -lockfile|WARN|.b.~lock~: failed to lock file: Resource deadlock avoided > -lockfile|WARN|.a.~lock~: failed to lock file: Resource deadlock avoided > + [lockfile|WARN|.a.~lock~: cannot lock file because this process has > already locked it > +lockfile|WARN|.b.~lock~: cannot lock file because this process has > already locked it > +lockfile|WARN|.b.~lock~: cannot lock file because this process has > already locked it > +lockfile|WARN|.a.~lock~: cannot lock file because this process has > already locked it > ]) > > CHECK_LOCKFILE([lock_symlink_to_dir], [0], > - [lockfile|WARN|dir/.b.~lock~: failed to lock file: Resource deadlock > avoided > + [lockfile|WARN|dir/.b.~lock~: cannot lock file because this process has > already locked it > ]) > -- > 1.7.10.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev >
_______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev