fix deadlock bug