avf: fix race between avf and cli/api process