lock XMPP for as little time as possible