socket-util: Make get_max_fds() and get_null_fd() thread-safe.