Fixed a bug that could cause a deadlock in fence with a very long wait time.