X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Flockfile.c;h=e0f6328710bd6ab52e4cd0e7a81428f923d8a720;hb=9360d9b7b50c52298c9bd47ab07b5c8c8ae074de;hp=100440e93614ca92db6255d25f8c09756b474532;hpb=3cfafd474026fd751765300fa462da2358379297;p=sliver-openvswitch.git diff --git a/lib/lockfile.c b/lib/lockfile.c index 100440e93..e0f632871 100644 --- a/lib/lockfile.c +++ b/lib/lockfile.c @@ -1,4 +1,4 @@ - /* Copyright (c) 2008, 2009, 2010 Nicira Networks + /* Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,15 @@ #include "hmap.h" #include "timeval.h" #include "util.h" - -#define THIS_MODULE VLM_lockfile #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(lockfile); + +COVERAGE_DEFINE(lockfile_lock); +COVERAGE_DEFINE(lockfile_timeout); +COVERAGE_DEFINE(lockfile_error); +COVERAGE_DEFINE(lockfile_unlock); + struct lockfile { struct hmap_node hmap_node; char *name; @@ -106,17 +111,12 @@ lockfile_lock(const char *file, int timeout, struct lockfile **lockfilep) } } while (error == EINTR && (timeout == INT_MAX || elapsed < timeout)); - if (!error) { - if (elapsed) { - VLOG_WARN("%s: waited %lld ms for lock file", - lock_name, elapsed); - } - } else if (error == EINTR) { + if (error == EINTR) { COVERAGE_INC(lockfile_timeout); VLOG_WARN("%s: giving up on lock file after %lld ms", lock_name, elapsed); error = ETIMEDOUT; - } else { + } else if (error) { COVERAGE_INC(lockfile_error); if (error == EACCES) { error = EAGAIN; @@ -151,7 +151,7 @@ lockfile_postfork(void) { struct lockfile *lockfile; - HMAP_FOR_EACH (lockfile, struct lockfile, hmap_node, &lock_table) { + HMAP_FOR_EACH (lockfile, hmap_node, &lock_table) { if (lockfile->fd >= 0) { VLOG_WARN("%s: child does not inherit lock", lockfile->name); lockfile_unhash(lockfile); @@ -171,7 +171,7 @@ lockfile_find(dev_t device, ino_t inode) { struct lockfile *lockfile; - HMAP_FOR_EACH_WITH_HASH (lockfile, struct lockfile, hmap_node, + HMAP_FOR_EACH_WITH_HASH (lockfile, hmap_node, lockfile_hash(device, inode), &lock_table) { if (lockfile->device == device && lockfile->inode == inode) { return lockfile;