// ZMQ_TCP_MAXRT: Retrieve Max TCP Retransmit Timeout
//
// Returns ErrorNotImplemented42 with ZeroMQ version < 4.2
//
// See: http://api.zeromq.org/4-2:zmq-getsockopt#toc44
344651
func (soc *Socket) GetTcpMaxrt() (time.Duration, error) {
	if minor < 2 {
		return time.Duration(0), ErrorNotImplemented42
	}
	v, err := soc.getInt(C.ZMQ_TCP_MAXRT)
	return time.Duration(v) * time.Millisecond, err
}
1134617
func (soc *Socket) SetVmciBufferMaxSize(value uint64) error {
	if minor < 2 {
		return ErrorNotImplemented42
	}
	return soc.setUInt64(C.ZMQ_VMCI_BUFFER_MAX_SIZE, value)
}
461659
func WithMaxConnectAttempts(value uint) options.Opt {
	return func(p options.Params) {
		if setter, ok := p.(maxConnectAttemptsSetter); ok {
			setter.SetMaxConnectAttempts(value)
		}
	}
}
1308661
func (mem *Mempool) ReapMaxTxs(max int) types.Txs {
	mem.proxyMtx.Lock()
	defer mem.proxyMtx.Unlock()

	if max < 0 {
		max = mem.txs.Len()
	}

	for atomic.LoadInt32(&mem.rechecking) > 0 {
		// TODO: Something better?
		time.Sleep(time.Millisecond * 10)
	}

	txs := make([]types.Tx, 0, cmn.MinInt(mem.txs.Len(), max))
	for e := mem.txs.Front(); e != nil && len(txs) <= max; e = e.Next() {
		memTx := e.Value.(*mempoolTx)
		txs = append(txs, memTx.tx)
	}
	return txs
}
1030046
func WithMaxReconnectAttempts(value uint) options.Opt {
	return func(p options.Params) {
		if setter, ok := p.(maxReconnectAttemptsSetter); ok {
			setter.SetMaxReconnectAttempts(value)
		}
	}
}
972498
func NewAMQPTarget(id string, args AMQPArgs) (*AMQPTarget, error) {
	var conn *amqp.Connection
	var err error
	// Retry 5 times with time interval of 2 seconds.
	for i := 1; i <= 5; i++ {
		conn, err = amqp.Dial(args.URL.String())
		if err == nil {
			break
		}
		if err != nil && i == 5 {
			return nil, err
		}
		time.Sleep(2 * time.Second)
	}

	return &AMQPTarget{
		id:   event.TargetID{ID: id, Name: "amqp"},
		args: args,
		conn: conn,
	}, nil
}
99714
func (dg *discoveryGateway) topologyWatcherMaxRefreshLag() time.Duration {
	var lag time.Duration
	for _, tw := range dg.tabletsWatchers {
		cellLag := tw.RefreshLag()
		if cellLag > lag {
			lag = cellLag
		}
	}
	return lag
}
913275
func (client *WANCommonInterfaceConfig1) GetMaximumActiveConnections() (NewMaximumActiveConnections uint16, err error) {
	// Request structure.
	request := interface{}(nil)
	// BEGIN Marshal arguments into request.

	// END Marshal arguments into request.

	// Response structure.
	response := &struct {
		NewMaximumActiveConnections string
	}{}

	// Perform the SOAP call.
	if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetMaximumActiveConnections", request, response); err != nil {
		return
	}

	// BEGIN Unmarshal arguments from response.

	if NewMaximumActiveConnections, err = soap.UnmarshalUi2(response.NewMaximumActiveConnections); err != nil {
		return
	}
	// END Unmarshal arguments from response.
	return
}
391348
func TCPSynOptions(wantOpts header.TCPSynOptions) TransportChecker {
	return func(t *testing.T, h header.Transport) {
		tcp, ok := h.(header.TCP)
		if !ok {
			return
		}
		opts := tcp.Options()
		limit := len(opts)
		foundMSS := false
		foundWS := false
		foundTS := false
		foundSACKPermitted := false
		tsVal := uint32(0)
		tsEcr := uint32(0)
		for i := 0; i < limit; {
			switch opts[i] {
			case header.TCPOptionEOL:
				i = limit
			case header.TCPOptionNOP:
				i++
			case header.TCPOptionMSS:
				v := uint16(opts[i+2])<<8 | uint16(opts[i+3])
				if wantOpts.MSS != v {
					t.Errorf("Bad MSS: got %v, want %v", v, wantOpts.MSS)
				}
				foundMSS = true
				i += 4
			case header.TCPOptionWS:
				if wantOpts.WS < 0 {
					t.Error("WS present when it shouldn't be")
				}
				v := int(opts[i+2])
				if v != wantOpts.WS {
					t.Errorf("Bad WS: got %v, want %v", v, wantOpts.WS)
				}
				foundWS = true
				i += 3
			case header.TCPOptionTS:
				if i+9 >= limit {
					t.Errorf("TS Option truncated , option is only: %d bytes, want 10", limit-i)
				}
				if opts[i+1] != 10 {
					t.Errorf("Bad length %d for TS option, limit: %d", opts[i+1], limit)
				}
				tsVal = binary.BigEndian.Uint32(opts[i+2:])
				tsEcr = uint32(0)
				if tcp.Flags()&header.TCPFlagAck != 0 {
					// If the syn is an SYN-ACK then read
					// the tsEcr value as well.
					tsEcr = binary.BigEndian.Uint32(opts[i+6:])
				}
				foundTS = true
				i += 10
			case header.TCPOptionSACKPermitted:
				if i+1 >= limit {
					t.Errorf("SACKPermitted option truncated, option is only : %d bytes, want 2", limit-i)
				}
				if opts[i+1] != 2 {
					t.Errorf("Bad length %d for SACKPermitted option, limit: %d", opts[i+1], limit)
				}
				foundSACKPermitted = true
				i += 2

			default:
				i += int(opts[i+1])
			}
		}

		if !foundMSS {
			t.Errorf("MSS option not found. Options: %x", opts)
		}

		if !foundWS && wantOpts.WS >= 0 {
			t.Errorf("WS option not found. Options: %x", opts)
		}
		if wantOpts.TS && !foundTS {
			t.Errorf("TS option not found. Options: %x", opts)
		}
		if foundTS && tsVal == 0 {
			t.Error("TS option specified but the timestamp value is zero")
		}
		if foundTS && tsEcr == 0 && wantOpts.TSEcr != 0 {
			t.Errorf("TS option specified but TSEcr is incorrect: got %d, want: %d", tsEcr, wantOpts.TSEcr)
		}
		if wantOpts.SACKPermitted && !foundSACKPermitted {
			t.Errorf("SACKPermitted option not found. Options: %x", opts)
		}
	}
}
895668
func (ni *VirNodeInfo) GetMaxCPUs() uint32 {
	return ni.GetNodes() * ni.GetSockets() * ni.GetCores() * ni.GetThreads()
}
1090928
func (soc *Socket) SetMulticastMaxtpdu(value int) error {
	if minor < 2 {
		return ErrorNotImplemented42
	}
	return soc.setInt(C.ZMQ_MULTICAST_MAXTPDU, value)
}
1128497
func (e *endpoint) GetSockOpt(opt interface{}) *tcpip.Error {
	switch o := opt.(type) {
	case tcpip.ErrorOption:
		return nil

	case *tcpip.SendBufferSizeOption:
		e.mu.Lock()
		*o = tcpip.SendBufferSizeOption(e.sndBufSize)
		e.mu.Unlock()
		return nil

	case *tcpip.ReceiveBufferSizeOption:
		e.rcvMu.Lock()
		*o = tcpip.ReceiveBufferSizeOption(e.rcvBufSizeMax)
		e.rcvMu.Unlock()
		return nil

	case *tcpip.ReceiveQueueSizeOption:
		e.rcvMu.Lock()
		if e.rcvList.Empty() {
			*o = 0
		} else {
			p := e.rcvList.Front()
			*o = tcpip.ReceiveQueueSizeOption(p.data.Size())
		}
		e.rcvMu.Unlock()
		return nil

	case *tcpip.KeepaliveEnabledOption:
		*o = 0
		return nil

	default:
		return tcpip.ErrUnknownProtocolOption
	}
}
141839
func (ctx *Context) GetMaxMsgsz() (int, error) {
	if minor < 2 {
		return 0, ErrorNotImplemented42
	}
	return getOption(ctx, C.ZMQ_MAX_MSGSZ)
}
895193
func ZmqRequestSocket(ip string, request_ports []int) *zmq.Socket {
	context, _ := zmq.NewContext()
	socket, _ := context.NewSocket(zmq.REQ)
	for _, _port := range request_ports {
		socket.Connect(fmt.Sprintf("tcp://%s:%d", ip, _port))
	}
	return socket
}
1067859
func tcpTimeStamp(offset uint32) uint32 {
	now := time.Now()
	return uint32(now.Unix()*1000+int64(now.Nanosecond()/1e6)) + offset
}
227990
func (q *QR) GetQRTicket(tq *Request) (t *Ticket, err error) {
	accessToken, err := q.GetAccessToken()
	if err != nil {
		return
	}

	uri := fmt.Sprintf(qrCreateURL, accessToken)
	response, err := util.PostJSON(uri, tq)
	if err != nil {
		err = fmt.Errorf("get qr ticket failed, %s", err)
		return
	}

	t = new(Ticket)
	err = json.Unmarshal(response, &t)
	if err != nil {
		return
	}

	return
}
95572
func retransmitLimit(retransmitMult, n int) int {
	nodeScale := math.Ceil(math.Log10(float64(n + 1)))
	limit := retransmitMult * int(nodeScale)
	return limit
}