diff options
author | Yunchih Chen <yunchih.cat@gmail.com> | 2017-12-05 22:17:02 +0800 |
---|---|---|
committer | Yunchih Chen <yunchih.cat@gmail.com> | 2017-12-05 22:17:02 +0800 |
commit | 79283280080b3a99c8a2a805f89f8035bc0189eb (patch) | |
tree | a1db58e494b9641965060d2b9adc23abe942e134 | |
parent | 34ea59f0ffb8ed55fb738c0cec7ba2645b56e302 (diff) | |
download | nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.tar nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.tar.gz nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.tar.bz2 nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.tar.lz nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.tar.xz nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.tar.zst nfcollect-79283280080b3a99c8a2a805f89f8035bc0189eb.zip |
Fix trunk size calculation
-rw-r--r-- | main.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -120,7 +120,8 @@ int main(int argc, char *argv[]) { ERR(signal(SIGHUP, sig_handler) == SIG_ERR, "Could not set SIGHUP handler"); uint32_t pgsize = getpagesize(); - uint32_t trunk_size_byte = storage_size / TRUNK_SIZE * 1024 * 1024; // MiB + uint32_t trunk_size_byte = (storage_size * 1024 * 1024) / TRUNK_SIZE ; // MiB + trunk_size_byte = (trunk_size_byte < TRUNK_SIZE) ? TRUNK_SIZE : trunk_size_byte; trunk_size_byte = (trunk_size_byte / pgsize) * pgsize; // align with pagesize uint32_t trunk_cnt = CEILING(storage_size, trunk_size_byte); @@ -131,8 +132,7 @@ int main(int argc, char *argv[]) { sem_init(&nfl_commit_queue, 0, max_commit_worker); // Set up nflog receiver worker - nflog_state_t **trunks = (nflog_state_t **)malloc( - sizeof(nflog_state_t *) * trunk_cnt); + nflog_state_t **trunks = (nflog_state_t **)malloc(sizeof(void*) * trunk_cnt); for (i = 0; i < trunk_cnt; ++i) { trunks[i] = NULL; } |