state: handle concurrent calls to SetAPIHostPorts