OLD | NEW |
---|---|
1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. | 1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. See the AUTHORS file for names of contributors. | 3 // found in the LICENSE file. See the AUTHORS file for names of contributors. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 } | 61 } |
62 | 62 |
63 int fflush_wrapper(FILE *file) { | 63 int fflush_wrapper(FILE *file) { |
64 return fflush(file); | 64 return fflush(file); |
65 } | 65 } |
66 | 66 |
67 #if !defined(OS_ANDROID) | 67 #if !defined(OS_ANDROID) |
68 int fdatasync(int fildes) { | 68 int fdatasync(int fildes) { |
69 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
70 return _commit(fildes); | 70 return _commit(fildes); |
71 #elif defined(OS_MACOSX) | |
72 return HANDLE_EINTR(fcntl(fildes, F_FULLFSYNC, 0)); | |
jsbell
2013/09/04 23:59:34
Can fcntl() produce an EINTR error on MacOS with F
dgrogan
2013/09/05 00:01:32
Yeah, I added it just in case the man page was inc
| |
71 #else | 73 #else |
72 return HANDLE_EINTR(fsync(fildes)); | 74 return HANDLE_EINTR(fsync(fildes)); |
73 #endif | 75 #endif |
74 } | 76 } |
75 #endif | 77 #endif |
76 | 78 |
77 #else | 79 #else |
78 | 80 |
79 class TryToLockFILE { | 81 class TryToLockFILE { |
80 // This class should be deleted if it doesn't turn up anything useful after | 82 // This class should be deleted if it doesn't turn up anything useful after |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 | 505 |
504 Status ChromiumWritableFile::Sync() { | 506 Status ChromiumWritableFile::Sync() { |
505 TRACE_EVENT0("leveldb", "ChromiumEnv::Sync"); | 507 TRACE_EVENT0("leveldb", "ChromiumEnv::Sync"); |
506 Status result; | 508 Status result; |
507 int error = 0; | 509 int error = 0; |
508 | 510 |
509 if (HANDLE_EINTR(fflush_wrapper(file_))) | 511 if (HANDLE_EINTR(fflush_wrapper(file_))) |
510 error = errno; | 512 error = errno; |
511 // Sync even if fflush gave an error; perhaps the data actually got out, | 513 // Sync even if fflush gave an error; perhaps the data actually got out, |
512 // even though something went wrong. | 514 // even though something went wrong. |
513 if (fdatasync(fileno(file_)) && !error) | 515 if (fdatasync(fileno(file_)) == -1 && !error) |
jsbell
2013/09/04 23:59:34
Nice catch.
| |
514 error = errno; | 516 error = errno; |
515 // Report the first error we found. | 517 // Report the first error we found. |
516 if (error) { | 518 if (error) { |
517 result = MakeIOError(filename_, strerror(error), kWritableFileSync, error); | 519 result = MakeIOError(filename_, strerror(error), kWritableFileSync, error); |
518 uma_logger_->RecordErrorAt(kWritableFileSync); | 520 uma_logger_->RecordErrorAt(kWritableFileSync); |
519 } | 521 } |
520 return result; | 522 return result; |
521 } | 523 } |
522 | 524 |
523 ChromiumEnv::ChromiumEnv() | 525 ChromiumEnv::ChromiumEnv() |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
957 Env* IDBEnv() { | 959 Env* IDBEnv() { |
958 return leveldb_env::idb_env.Pointer(); | 960 return leveldb_env::idb_env.Pointer(); |
959 } | 961 } |
960 | 962 |
961 Env* Env::Default() { | 963 Env* Env::Default() { |
962 return leveldb_env::default_env.Pointer(); | 964 return leveldb_env::default_env.Pointer(); |
963 } | 965 } |
964 | 966 |
965 } // namespace leveldb | 967 } // namespace leveldb |
966 | 968 |
OLD | NEW |