mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Fixed ledger read fd leak. Reordered subsystem init. (#138)
This commit is contained in:
@@ -333,6 +333,7 @@ namespace ledger
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == -1)
|
||||
{
|
||||
close(fd);
|
||||
LOG_ERROR << errno << ": Error in ledger file stat. " << file_path;
|
||||
return -1;
|
||||
}
|
||||
@@ -340,10 +341,12 @@ namespace ledger
|
||||
buffer.resize(st.st_size);
|
||||
if (read(fd, buffer.data(), buffer.size()) == -1)
|
||||
{
|
||||
close(fd);
|
||||
LOG_ERROR << errno << ": Error reading ledger file. " << file_path;
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
22
src/main.cpp
22
src/main.cpp
@@ -68,14 +68,14 @@ int parse_cmd(int argc, char **argv)
|
||||
*/
|
||||
void deinit()
|
||||
{
|
||||
consensus::deinit();
|
||||
ledger::deinit();
|
||||
state_sync::deinit();
|
||||
state_serve::deinit();
|
||||
read_req::deinit();
|
||||
sc::deinit();
|
||||
usr::deinit();
|
||||
p2p::deinit();
|
||||
read_req::deinit();
|
||||
consensus::deinit();
|
||||
state_sync::deinit();
|
||||
state_serve::deinit();
|
||||
sc::deinit();
|
||||
ledger::deinit();
|
||||
}
|
||||
|
||||
void sigint_handler(int signum)
|
||||
@@ -192,14 +192,14 @@ int main(int argc, char **argv)
|
||||
<< (conf::cfg.startup_mode == conf::OPERATING_MODE::OBSERVER ? "Observer" : "Proposer");
|
||||
LOG_INFO << "Public key: " << conf::cfg.pubkeyhex.substr(2); // Public key without 'ed' prefix.
|
||||
|
||||
if (p2p::init() != 0 ||
|
||||
usr::init() != 0 ||
|
||||
if (ledger::init() ||
|
||||
sc::init() ||
|
||||
read_req::init() != 0 ||
|
||||
state_serve::init() != 0 ||
|
||||
state_sync::init() != 0 ||
|
||||
ledger::init() ||
|
||||
consensus::init() != 0)
|
||||
consensus::init() != 0 ||
|
||||
read_req::init() != 0 ||
|
||||
p2p::init() != 0 ||
|
||||
usr::init() != 0)
|
||||
{
|
||||
deinit();
|
||||
return -1;
|
||||
|
||||
@@ -310,6 +310,7 @@ namespace sc
|
||||
// Write the json message and close write fd.
|
||||
if (write(stdinpipe[1], json.data(), json.size()) == -1)
|
||||
{
|
||||
close(stdinpipe[1]);
|
||||
LOG_ERROR << errno << ": Failed to write to stdin of contract process.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user