Fixed disk io error - set fds to -1 when closing in hpws parent process (#254)

This commit is contained in:
Chalith Desaman
2021-02-23 12:23:55 +05:30
committed by GitHub
parent ff197a8bb6
commit 312713c296
3 changed files with 8 additions and 3 deletions

View File

@@ -386,8 +386,11 @@ namespace hpws
// --- PARENT
// Fds are set to -1, so when error occurred these fds won't get closed again.
::close(fd[1]);
fd[1] = -1;
::close(fd[3]);
fd[3] = -1;
int child_fd[2] = {fd[0], fd[2]};
@@ -776,7 +779,7 @@ namespace hpws
if (HPWS_DEBUG)
fprintf(stderr, "[HPWS.HPP] 'r%c' received on child_fd[%d]=%d\n", rbuf[1], i, child_fd[i]);
}
if (HPWS_DEBUG)
fprintf(stderr, "[HPWS.HPP] Accept[13] called %d\n", calls);
}
@@ -886,7 +889,9 @@ namespace hpws
// --- PARENT
// Fds are set to -1, so when error occurred these fds won't get closed again.
::close(fd[1]);
fd[1] = -1;
int flags = fcntl(fd[0], F_GETFD, NULL);
if (flags < 0)

View File

@@ -287,7 +287,6 @@ namespace ledger::sqlite
if (sqlite3_prepare_v2(db, sql.data(), -1, &stmt, 0) == SQLITE_OK &&
stmt != NULL && sqlite3_step(stmt) == SQLITE_ROW)
{
// Finalize and distroys the statement.
ledger.seq_no = sqlite3_column_int64(stmt, 0);
ledger.time = sqlite3_column_int64(stmt, 1);
ledger.ledger_hash_hex = std::string((char *)sqlite3_column_text(stmt, 2));
@@ -300,6 +299,7 @@ namespace ledger::sqlite
ledger.output_hash_hex = std::string((char *)sqlite3_column_text(stmt, 9));
}
// Finalize and distroys the statement.
sqlite3_finalize(stmt);
return ledger;
}

View File

@@ -54,7 +54,7 @@ namespace ledger::sqlite
std::string input_hash_hex;
std::string output_hash_hex;
ledger() {};
ledger(){};
ledger(
const uint64_t seq_no,