diff options
author | Ben Pfaff <blp@nicira.com> | 2010-02-15 11:31:32 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-02-15 11:31:32 -0800 |
commit | 7446f1480bb27ccb63feab066d901cc940d52462 (patch) | |
tree | 9135e88fc73dd1c8dfa352bdd25b90a8abb2c0e4 /ovsdb/file.c | |
parent | 475afa1b2c0ced20b47ef8cba25ad5d59c560a08 (diff) | |
download | openvswitch-7446f1480bb27ccb63feab066d901cc940d52462.tar.gz |
ovsdb: Allow ovsdb_log_open()'s caller to choose whether to lock.
The current callers of ovsdb_log_open() always want to lock the file if
they are accessing it for read/write access. An upcoming commit will add
a new caller that does not fit this model (it wants to lock the file
across a wider region) and so the caller should be able to choose whether
to do locking. This commit adds that ability.
Also, get rid of the use of <fcntl.h> flags to choose the open mode, which
has always seemed somewhat crude and which this change would make even
cruder.
Diffstat (limited to 'ovsdb/file.c')
-rw-r--r-- | ovsdb/file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ovsdb/file.c b/ovsdb/file.c index 31086af84..3e07b8449 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -43,13 +43,15 @@ static void ovsdb_file_replica_create(struct ovsdb *, struct ovsdb_log *); struct ovsdb_error * ovsdb_file_open(const char *file_name, bool read_only, struct ovsdb **dbp) { + enum ovsdb_log_open_mode open_mode; struct ovsdb_schema *schema; struct ovsdb_error *error; struct ovsdb_log *log; struct json *json; struct ovsdb *db; - error = ovsdb_log_open(file_name, read_only ? O_RDONLY : O_RDWR, &log); + open_mode = read_only ? OVSDB_LOG_READ_ONLY : OVSDB_LOG_READ_WRITE; + error = ovsdb_log_open(file_name, open_mode, -1, &log); if (error) { return error; } |