Fix locking the mutex of the Port class