Fix race condition between merge and signal

Signed-off-by: task650 <task650@gmail.com>