#define END_CRIT_SECTION() do { \ Assert(CritSectionCount > 0); \ CritSectionCount--; \ } while (0)
在代码中我们可以看到这样一些调用:
1 2 3
START_CRIT_SECTION() ... END_CRIT_SECTION()
这两行代码不过是对一个CritSectionCount进行加减,怎么起到对关键区的保护?
解释
在errstart中,如果发生问题,有一个判断:
1 2 3 4 5 6 7 8 9 10 11
/* * Check some cases in which we want to promote an error into a more * severe error. None of this logic applies for non-error messages. */ if (elevel >= ERROR && u_sess != NULL) { /* * If we are inside a critical section, all errors become PANIC * errors. See miscadmin.h. */ if (t_thrd.int_cxt.CritSectionCount > 0) elevel = PANIC;