Ad Widget

Collapse

Short circuit evaluation for trigger expressions?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • azabbixuser
    Junior Member
    • Nov 2012
    • 3

    #1

    Short circuit evaluation for trigger expressions?

    I am trying to find out if Zabbix does short circuit evaluation with trigger expressions, particularly for the logical & operator.

    I've tried the search function for the forum.
    The Zabbix 1.8 book doesn't state it either.
    I've tried Google and the closest I can find is this link.
    Is the author saying that now it does do short circuit evaluation?
    I don't quite understand.

    Thanks
  • azabbixuser
    Junior Member
    • Nov 2012
    • 3

    #2
    I answered my own question: it does do short circuit evaluation.

    I looked at the source code, particularly the function "evaluate_simple" in the file src/libs/zbxserver/expression.c.

    A code snippet reveals this:

    Code:
    case '&':
    	*result = (SUCCEED != cmp_double(value1, 0) && SUCCEED != cmp_double(value2, 0));
    	break;
    There is no compiler directive present that turns off short circuit evaluation. So, however C does it, is the way Zabbix does it. Case closed.

    Comment

    Working...