瀏覽代碼

Prevent handle used for LOG from being inherited by subprocesses

I recently encountered a problem with this because Windows doesn't allow
files to be deleted when there's open handles to them.

Other files opened by leveldb are not affected because by and large they
are using CreateFileA, which does not allow inheritance when
lpSecurityAttributes is null (ref:
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea)

However, fopen() _does_ allow inheritance, and it needs to be expressly
disabled.
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-160
naive_version
Dylan K. Taylor 3 年之前
父節點
當前提交
68d14a723a
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 8927471A91CAFD3D
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. +1
    -1
      util/env_windows.cc

+ 1
- 1
util/env_windows.cc 查看文件

@ -622,7 +622,7 @@ class WindowsEnv : public Env {
}
Status NewLogger(const std::string& filename, Logger** result) override {
std::FILE* fp = std::fopen(filename.c_str(), "w");
std::FILE* fp = std::fopen(filename.c_str(), "wN");
if (fp == nullptr) {
*result = nullptr;
return WindowsError(filename, ::GetLastError());

Loading…
取消
儲存