Correct potenital locking issue in msg allocation