top_of_rend_pqueue_is_worthwhile requires a nonempty queue.
return count;
}
-/** Peek at the top entry on the pending rend pqueue. If its level of
- * effort is at least what we're suggesting for that service right now,
- * return 1, else return 0.
+/** Peek at the top entry on the pending rend pqueue, which must not be empty.
+ * If its level of effort is at least what we're suggesting for that service
+ * right now, return 1, else return 0.
*/
int
top_of_rend_pqueue_is_worthwhile(hs_pow_service_state_t *pow_state)
/* If we had a queue during this period, and the current top of queue
* is at or above the suggested effort, we should re-estimate the effort.
* Otherwise, it can stay the same (no change to effort). */
- if (top_of_rend_pqueue_is_worthwhile(pow_state)) {
+ if (smartlist_len(pow_state->rend_request_pqueue) > 0 &&
+ top_of_rend_pqueue_is_worthwhile(pow_state)) {
pow_state->suggested_effort = (uint32_t)(pow_state->total_effort /
pow_state->rend_handled);
}