Reorder lock acquision vs try.

In two places involving locking, reordered the code so that the lock
acquisition is performed outside of the `try` block and everything
else that needs to run while the lock is locked *within* the `try`
block.

Change-Id: I3dad2c4bbf60b219fc6db2aa35e2ed296cb39128
1 file changed