MT#5715 use locking before write to fifo

(cherry picked from commit 36798db53e111a2196e7ae16dcfc6abe993a1948)