projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
random: Get random seed from /dev/urandom.
[openvswitch]
/
lib
/
lockfile.c
diff --git
a/lib/lockfile.c
b/lib/lockfile.c
index e5a041eed4cfc195b2cd39af310afc051648a61a..84bfb3c04061bfa52c8b37aaac944de6e8ee9e42 100644
(file)
--- a/
lib/lockfile.c
+++ b/
lib/lockfile.c
@@
-1,4
+1,4
@@
- /* Copyright (c) 2008, 2009 Nicira Networks
+ /* Copyright (c) 2008, 2009
, 2010
Nicira Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* 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,10
@@
#include "hmap.h"
#include "timeval.h"
#include "util.h"
#include "hmap.h"
#include "timeval.h"
#include "util.h"
-
-#define THIS_MODULE VLM_lockfile
#include "vlog.h"
#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(lockfile)
+
struct lockfile {
struct hmap_node hmap_node;
char *name;
struct lockfile {
struct hmap_node hmap_node;
char *name;
@@
-61,8
+61,8
@@
lockfile_name(const char *file_name)
{
const char *slash = strrchr(file_name, '/');
return (slash
{
const char *slash = strrchr(file_name, '/');
return (slash
- ? xasprintf("%.*s/.%s.~lock~",
slash - file_name, file_name,
- slash + 1)
+ ? xasprintf("%.*s/.%s.~lock~",
+
(int) (slash - file_name), file_name,
slash + 1)
: xasprintf(".%s.~lock~", file_name));
}
: xasprintf(".%s.~lock~", file_name));
}
@@
-84,6
+84,7
@@
lockfile_lock(const char *file, int timeout, struct lockfile **lockfilep)
* because the Open vSwitch code that currently uses lock files does so in
* stylized ways such that any number of readers may access a file while it
* is being written. */
* because the Open vSwitch code that currently uses lock files does so in
* stylized ways such that any number of readers may access a file while it
* is being written. */
+ long long int warn_elapsed = 1000;
long long int start, elapsed;
char *lock_name;
int error;
long long int start, elapsed;
char *lock_name;
int error;
@@
-98,6
+99,11
@@
lockfile_lock(const char *file, int timeout, struct lockfile **lockfilep)
error = lockfile_try_lock(lock_name, timeout > 0, lockfilep);
time_refresh();
elapsed = time_msec() - start;
error = lockfile_try_lock(lock_name, timeout > 0, lockfilep);
time_refresh();
elapsed = time_msec() - start;
+ if (elapsed > warn_elapsed) {
+ warn_elapsed *= 2;
+ VLOG_WARN("%s: waiting for lock file, %lld ms elapsed",
+ lock_name, elapsed);
+ }
} while (error == EINTR && (timeout == INT_MAX || elapsed < timeout));
if (!error) {
} while (error == EINTR && (timeout == INT_MAX || elapsed < timeout));
if (!error) {