Change locking structure in p2pclient/serverprocess for robustness