Backported from RCPTT.

RCPTT commit: f3a219235f9af3475d6a1d7a0cfacee5c76f3622