Added a ReentrantReadWriteLock to guard against a service call executing while a connection is being shutdown.