Bug #3503
closed
Assertion `nMaxEntries > 0' failed with cs_max_packets == 0
Added by Davide Pesavento over 8 years ago.
Updated over 8 years ago.
Description
We should print a nice error message instead of crashing.
[...]
1457018941.499514 INFO: [TablesConfigSection] Setting CS max packets to 0
nfd: ../daemon/table/cs-policy.cpp:44: void nfd::cs::Policy::setLimit(std::size_t): Assertion `nMaxEntries > 0' failed.
In fact, why can't nMaxEntries
(i.e. cs::Policy::m_limit
) be zero? I don't see an obvious reason for this restriction, and it could be a useful setting for testing.
- Assignee set to Minsheng Zhang
cs::Policy::setLimit
has no nMaxEntries > 0
declaration in Doxygen.
If this condition is in fact needed for all policies, it should be declared as part of \param
, and the caller has the responsibility to ensure the argument is positive;
if this condition is only needed for some policies, it should be mentioned in a \throw
, and the callee should use an exception rather than an assertion to check the condition, and the caller may catch the exception and produce an error message.
It's wrong for cs::Policy::setLimit
to print an error message and retain the previous setting, because this would admit an incorrect configuration file.
I'm assigning this to @MinSheng who authored cs-policy.hpp
.
@David and @Junxiao, I agree that nMaxEntries would be zero and will change codes if there is no exception.
- % Done changed from 0 to 80
- Status changed from New to Code review
- % Done changed from 80 to 100
- Status changed from Code review to Closed
Also available in: Atom
PDF