I don't think we need to be holding this lock for anything except (probably? maybe not even here) set_socket_options(). Leaving it here it's just protecting a bunch of function-local initialization.