// ConnectionState returns basic TLS details about the connection.
191798
func (c *Conn) ConnectionState() ConnectionState {
	c.handshakeMutex.Lock()
	defer c.handshakeMutex.Unlock()

	var state ConnectionState
	state.HandshakeComplete = c.handshakeComplete
	if c.handshakeComplete {
		state.Version = c.vers
		state.NegotiatedProtocol = c.clientProtocol
		state.DidResume = c.didResume
		state.NegotiatedProtocolIsMutual = !c.clientProtocolFallback
		state.CipherSuite = c.cipherSuite
		state.PeerCertificates = c.peerCertificates
		state.VerifiedChains = c.verifiedChains
		state.ServerName = c.serverName
		state.SignedCertificateTimestamps = c.scts
		state.OCSPResponse = c.ocspResponse
		if !c.didResume {
			state.TLSUnique = c.firstFinished[:]
		}
	}

	return state
}
1145750
func (rg *RecordGenerator) ParseState(c Config, masters ...string) error {
	// find master -- return if error
	sj, err := rg.stateLoader(masters)
	if err != nil {
		logging.Error.Println("Failed to fetch state. Error: ", err)
		return err
	}
	if sj.Leader == "" {
		logging.Error.Println("Unexpected error")
		err = errors.New("empty master")
		return err
	}

	hostSpec := labels.RFC1123
	if c.EnforceRFC952 {
		hostSpec = labels.RFC952
	}

	return rg.InsertState(sj, c.Domain, c.SOAMname, c.Listener, masters, c.IPSources, hostSpec)
}
961405
func BuildState(cb func(*SyncState)) *State {
	s := NewState()
	cb(s.SyncWrapper())
	return s
}
48557
func (s *WorkspaceConnectionStatus) SetConnectionState(v string) *WorkspaceConnectionStatus {
	s.ConnectionState = &v
	return s
}
1206041
func (c *ConnReq) State() ConnState {
	c.stateMtx.RLock()
	state := c.state
	c.stateMtx.RUnlock()
	return state
}
199936
func (p *StatePool) SystemState() *State {
	p.mu.Lock()
	defer p.mu.Unlock()
	// State pool is closed, no more access to the system state.
	if p.pool == nil {
		return nil
	}
	return p.systemState
}
8131
func GetDocknetState(tenantName, networkName, serviceName string) (*DnetOperState, error) {
	log.Infof("GetDocknetState for %s.%s.%s", tenantName, networkName, serviceName)

	// Get the state driver
	stateDriver, err := utils.GetStateDriver()
	if err != nil {
		log.Warnf("Couldn't get state driver for docknet %v", err)
		return nil, err
	}

	// save docknet oper state
	dnetOper := DnetOperState{}
	dnetOper.ID = fmt.Sprintf("%s.%s.%s", tenantName, networkName, serviceName)
	dnetOper.StateDriver = stateDriver

	// Read the dnet oper state
	err = dnetOper.Read(dnetOper.ID)
	if err == nil {
		return &dnetOper, nil
	}
	return nil, err
}
1184517
func (c *Client) Connect() {
	for c.GetState() == DisconnectedState {
		go c.resubscribe()
		c.doConnection()
		time.Sleep(c.policy.Next())
	}

	c.setState(ClosedState)
}
1338433
func (s *Session) SetConnectionState(v string) *Session {
	s.ConnectionState = &v
	return s
}
1281094
func (d *Datapath) netRetrieveState(p *packet.Packet) (*connection.TCPConnection, error) {
	hash := p.L4FlowHash()

	// Did we see a network syn/ack packet? (PU is a client)
	conn, err := d.netReplyConnectionTracker.GetReset(hash, 0)
	if err == nil {
		if err = updateTimer(d.netReplyConnectionTracker, hash, conn.(*connection.TCPConnection)); err != nil {
			return nil, err
		}

		return conn.(*connection.TCPConnection), nil
	}

	// Did we see a network Syn packet before? (PU is a server)
	conn, err = d.netOrigConnectionTracker.GetReset(hash, 0)
	if err == nil {
		if err = updateTimer(d.netOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); err != nil {
			return nil, err
		}

		return conn.(*connection.TCPConnection), nil
	}

	// We reach in this state for a client PU only when the service connection(encrypt) sends data sparsely.
	// Packets are dropped when this happens, and that is a BUG!!!
	// For the server PU we mark the connection in the unknown state.
	if p.GetTCPFlags()&packet.TCPSynAckMask == packet.TCPAckMask {
		// Let's try if its an existing connection
		context, cerr := d.contextFromIP(false, p.Mark, p.DestPort(), packet.IPProtocolTCP)
		if cerr != nil {
			return nil, err
		}
		conn = connection.NewTCPConnection(context, p)
		conn.(*connection.TCPConnection).SetState(connection.UnknownState)
		return conn.(*connection.TCPConnection), nil
	}

	return nil, errInvalidNetState
}
115143
func (vrsConnection VRSConnection) GetPortState(name string) (map[port.StateKey]interface{}, error) {

	readRowArgs := ovsdb.ReadRowArgs{
		Columns: []string{ovsdb.NuagePortTableColumnIPAddress, ovsdb.NuagePortTableColumnSubnetMask,
			ovsdb.NuagePortTableColumnGateway, ovsdb.NuagePortTableColumnEVPNID,
			ovsdb.NuagePortTableColumnVRFId},
		Condition: []string{ovsdb.NuagePortTableColumnName, "==", name},
	}

	var row map[string]interface{}
	var err error
	if row, err = vrsConnection.portTable.ReadRow(vrsConnection.ovsdbClient, readRowArgs); err != nil {
		return make(map[port.StateKey]interface{}), fmt.Errorf("Unable to obtain the port row %v", err)
	}

	portState := make(map[port.StateKey]interface{})
	portState[port.StateKeyIPAddress] = row[ovsdb.NuagePortTableColumnIPAddress]
	portState[port.StateKeySubnetMask] = row[ovsdb.NuagePortTableColumnSubnetMask]
	portState[port.StateKeyGateway] = row[ovsdb.NuagePortTableColumnGateway]
	portState[port.StateKeyVrfID] = row[ovsdb.NuagePortTableColumnVRFId]
	portState[port.StateKeyEvpnID] = row[ovsdb.NuagePortTableColumnEVPNID]

	return portState, nil
}
656534
func (tsv *TabletServer) GetState() string {
	if tsv.lameduck.Get() != 0 {
		return "NOT_SERVING"
	}
	tsv.mu.Lock()
	name := stateName[tsv.state]
	tsv.mu.Unlock()
	return name
}
1352085
func (c *Container) CurrentState() ContainerState {
	c.status.RLock()
	current := c.status.State
	c.status.RUnlock()

	return current
}
904439
func IsValidState(conn client.Connection, req StateRequest) (bool, error) {
	logger := plog.WithFields(log.Fields{
		"hostid":     req.HostID,
		"serviceid":  req.ServiceID,
		"instanceid": req.InstanceID,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	hspth := path.Join(basepth, "/hosts", req.HostID, "instances", req.StateID())
	if ok, err := conn.Exists(hspth); err != nil {

		logger.WithError(err).Debug("Could not look up host state")
		return false, &StateError{
			Request:   req,
			Operation: "exists",
			Message:   "could not look up host state",
		}
	} else if !ok {

		logger.Debug("Host state not found")
		return false, nil
	}

	logger.Debug("Found the host state")

	sspth := path.Join(basepth, "/services", req.ServiceID, req.StateID())
	if ok, err := conn.Exists(sspth); err != nil {
		logger.WithError(err).Debug("Could not look up service state")
		return false, &StateError{
			Request:   req,
			Operation: "exists",
			Message:   "could not look up service state",
		}
	} else if !ok {
		logger.Debug("Service state not found")
		return false, nil
	}

	cspth := path.Join(sspth, "current")
	if ok, err := conn.Exists(cspth); err != nil {
		logger.WithError(err).Debug("Could not look up current state (status)")
		return false, &StateError{
			Request:   req,
			Operation: "exists",
			Message:   "could not look up current state (status)",
		}
	} else if !ok {
		logger.Debug("Service status not found")
		return false, nil
	}

	logger.Debug("Found the service state")
	return true, nil
}
948643
func (c Client) GetDatasetState(datasetID string) (*DatasetState, error) {
	resp, err := c.get(c.getURL("state/datasets"))
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	var states []datasetStatePayload
	if err = json.NewDecoder(resp.Body).Decode(&states); err == nil {
		for _, s := range states {
			if s.DatasetID == datasetID {
				return s.DatasetState, nil
			}
		}
		return nil, errStateNotFound
	}

	return nil, err
}
899373
func (c *ConsulProvider) getState() (uint64, *structs.CAConsulProviderState, error) {
	state := c.Delegate.State()
	idx, providerState, err := state.CAProviderState(c.id)
	if err != nil {
		return 0, nil, err
	}

	if providerState == nil {
		return 0, nil, ErrNotInitialized
	}

	return idx, providerState, nil
}
724642
func (v *vserver) updateState(ip seesaw.IP) {
	// A vserver anycast IP is healthy if *all* services for that IP are healthy.
	// A vserver unicast IP is healthy if *any* services for that IP are healthy.
	var healthy bool
	for _, s := range v.services {
		if !s.ip.Equal(ip) {
			continue
		}
		healthy = s.healthy
		if !healthy && seesaw.IsAnycast(ip.IP()) {
			break
		}
		if healthy && !seesaw.IsAnycast(ip.IP()) {
			break
		}
	}

	if v.active[ip] == healthy {
		v.updateServices(ip)
		return
	}
	switch {
	case !healthy && v.active[ip]:
		v.down(ip)
	case healthy && !v.active[ip]:
		v.up(ip)
	}
}