fixes #506 Take no locks for getting/setting diagnostics logging (the
race condition is benign - the underlying diag file never closes)

fixes #508 Take a read lock first when trying to profile, and catch
retrywithwritelock before taking the write lock.