Fix race in setting plugin refcounts. Upstream-commit: 86a0de7fa9fe34d29cffc8fcffe0b81b0db78a87 Component: engine