SERVER-14186 check for ismaster under write lock

We need to check master-ness under a write lock before doing a logOp() or else
the server might shut down.