Fix race condition in connecting inproc sockets