backport MockSnmpAgent atomic fixes from master