The reason defer isn't used here is the call to setDomainService() below, which it turn locks itself, and the lock isn't re-entrant. The reason setDomainService() is called during domain removal is to trigger the service refcount cleanup code, which I wanted to share in this way.