From: Ben Pfaff Date: Wed, 11 Mar 2009 21:24:39 +0000 (-0700) Subject: lockfile: Remove fd parameter to remove_lockfile(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74493526eaa7f73acf2a2c6573751cf65e8e27bf;p=openvswitch lockfile: Remove fd parameter to remove_lockfile(). There is no reason that remove_lockfile() should close a fd passed in to it. The caller can do that just as well. --- diff --git a/lib/cfg.c b/lib/cfg.c index 29bc495b..ee5cf6fb 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -253,7 +253,10 @@ cfg_get_cookie(uint8_t *cookie) void cfg_unlock(void) { - remove_lockfile(lock_fd, lock_name); + if (lock_fd != -1) { + close(lock_fd); + } + remove_lockfile(lock_name); lock_fd = -1; } diff --git a/lib/lockfile.c b/lib/lockfile.c index 736a67c5..d98e97a5 100644 --- a/lib/lockfile.c +++ b/lib/lockfile.c @@ -28,18 +28,14 @@ fcntl_lock(int fd) return fcntl(fd, F_SETLK, &l) == -1 ? errno : 0; } -/* Remove the lockfile with 'name'. If the 'fd' argument is not -1, it - * will be closed. */ +/* Remove the lockfile with 'name'. */ int -remove_lockfile(int fd, const char *name) +remove_lockfile(const char *name) { char buffer[BUFSIZ]; ssize_t n; pid_t pid; - - if (fd != -1) { - close(fd); - } + int fd; /* Remove existing lockfile. */ fd = open(name, O_RDWR); @@ -118,7 +114,7 @@ create_lockfile(const char *name) int fd; /* Remove an existing lockfile if it was created by us. */ - int retval = remove_lockfile(-1, name); + int retval = remove_lockfile(name); if (!retval) { return retval; } diff --git a/lib/lockfile.h b/lib/lockfile.h index 645fd3d9..8e01c8f6 100644 --- a/lib/lockfile.h +++ b/lib/lockfile.h @@ -35,6 +35,6 @@ #define LOCKFILE_H 1 int create_lockfile(const char *name); -int remove_lockfile(int fd, const char *name); +int remove_lockfile(const char *name); #endif /* lockfile.h */