Factor out pthread_mutex_lock and unlock calls for the iolock.