Skip to content

Commit

Permalink
statshttpd: Fixed initialization cannot finished when only history sh…
Browse files Browse the repository at this point in the history
…ares in kafka.
  • Loading branch information
SwimmingTiger committed Jan 15, 2019
1 parent f9250a6 commit 7d24adf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/StatsHttpd.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,9 @@ void StatsServerT<SHARE>::runThreadConsume() {
rkmessage = kafkaConsumer_.consumer(kTimeoutMs);

if (rkmessage != nullptr) {
// record the latest time that got a non-empty message
lastCleanTime = time(nullptr);

// consume share log (lastShareTime_ will be updated)
consumeShareLog(rkmessage);
rd_kafka_message_destroy(rkmessage); /* Return message to rdkafka */
Expand All @@ -1110,8 +1113,8 @@ void StatsServerT<SHARE>::runThreadConsume() {
}

// the initialization state ends after no shares in 5 minutes
// LastCleanTime is used here because it records the time when the consuming thread starting
if (lastShareTime_ == 0 && lastCleanTime + 300 < time(nullptr)) {
// LastCleanTime is used here because it records the latest time that got a non-empty message
if (rkmessage == nullptr && lastCleanTime + 300 < time(nullptr)) {
isInitializing_ = false;
break;
}
Expand Down

0 comments on commit 7d24adf

Please sign in to comment.