close lock_fd if flock failed (#2231)

pull/2236/head
Dean Lee 2020-09-28 17:47:38 +08:00 committed by GitHub
parent 7d28afcde3
commit 9983389ffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -305,7 +305,10 @@ int read_db_all(std::map<std::string, std::string> *params, bool persistent_para
if (lock_fd < 0) return -1;
err = flock(lock_fd, LOCK_SH);
if (err < 0) return err;
if (err < 0) {
close(lock_fd);
return err;
}
std::string key_path = util::string_format("%s/d", params_path);
DIR *d = opendir(key_path.c_str());