diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-09-01 20:06:26 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-09-01 20:06:26 +0000 |
commit | f80ac31d742c2d86f1812b895ef61a5885e2447e (patch) | |
tree | 9b223723aced9e7a8acc55044120cc406c77bd9b /src/or/config.c | |
parent | 6a29ad853b630a1970fd95e17ecd79306e7c39e6 (diff) | |
download | tor-f80ac31d742c2d86f1812b895ef61a5885e2447e.tar tor-f80ac31d742c2d86f1812b895ef61a5885e2447e.tar.gz |
Add a lockfile to the Tor data directory to avoid situations where two Tors start with the same datadir, or where a --list-fingerprints races with a server to create keys, or such.
svn:r16722
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index 52c7f8b8a..7d9dc64b7 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1172,6 +1172,11 @@ options_act(or_options_t *old_options) int running_tor = options->command == CMD_RUN_TOR; char *msg; + if (running_tor && !have_lockfile()) { + if (try_locking(options, 1) < 0) + return -1; + } + if (consider_adding_dir_authorities(options, old_options) < 0) return -1; @@ -4883,10 +4888,10 @@ get_or_state(void) * Note: Consider using the get_datadir_fname* macros in or.h. */ char * -get_datadir_fname2_suffix(const char *sub1, const char *sub2, - const char *suffix) +options_get_datadir_fname2_suffix(or_options_t *options, + const char *sub1, const char *sub2, + const char *suffix) { - or_options_t *options = get_options(); char *fname = NULL; size_t len; tor_assert(options); |