TS-2174: Fix StatBinaryEval() on div operation We should fore the type of result to be RecFloat on div operation, otherwise we can't get the fraction when dividing two RecInt.
Signed-off-by: Yunkai Zhang <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/04e16af6 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/04e16af6 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/04e16af6 Branch: refs/heads/5.0.x Commit: 04e16af6dacb697ddcc373b046a7a412786caddc Parents: 8d95ab2 Author: Yunkai Zhang <[email protected]> Authored: Wed Sep 4 00:57:07 2013 +0800 Committer: Yunkai Zhang <[email protected]> Committed: Wed Sep 4 02:29:06 2013 +0800 ---------------------------------------------------------------------- mgmt/stats/StatType.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04e16af6/mgmt/stats/StatType.cc ---------------------------------------------------------------------- diff --git a/mgmt/stats/StatType.cc b/mgmt/stats/StatType.cc index 0017e5d..3e13d78 100644 --- a/mgmt/stats/StatType.cc +++ b/mgmt/stats/StatType.cc @@ -947,6 +947,22 @@ StatExprToken *StatObject::StatBinaryEval(StatExprToken * left, char op, case '/': RecData recTmp; RecDataClear(RECD_NULL, &recTmp); + + /* + * Force the type of result to be RecFloat on div operation + */ + if (result->m_token_type != RECD_FLOAT && result->m_token_type != RECD_CONST) { + RecFloat t; + + result->m_token_type = RECD_FLOAT; + + t = (RecFloat)l.rec_int; + l.rec_float = t; + + t = (RecFloat)r.rec_int; + r.rec_float = t; + } + if (RecDataCmp(result->m_token_type, r, recTmp)) { result->m_token_value = RecDataDiv(result->m_token_type, l, r); }
