// execute executes the TCP 3-way handshake.
192304
func (h *handshake) execute() *tcpip.Error {
	if h.ep.route.IsResolutionRequired() {
		if err := h.resolveRoute(); err != nil {
			return err
		}
	}

	// Initialize the resend timer.
	resendWaker := sleep.Waker{}
	timeOut := time.Duration(time.Second)
	rt := time.AfterFunc(timeOut, func() {
		resendWaker.Assert()
	})
	defer rt.Stop()

	// Set up the wakers.
	s := sleep.Sleeper{}
	s.AddWaker(&resendWaker, wakerForResend)
	s.AddWaker(&h.ep.notificationWaker, wakerForNotification)
	s.AddWaker(&h.ep.newSegmentWaker, wakerForNewSegment)
	defer s.Done()

	var sackEnabled SACKEnabled
	if err := h.ep.stack.TransportProtocolOption(ProtocolNumber, &sackEnabled); err != nil {
		// If stack returned an error when checking for SACKEnabled
		// status then just default to switching off SACK negotiation.
		sackEnabled = false
	}

	// Send the initial SYN segment and loop until the handshake is
	// completed.
	synOpts := header.TCPSynOptions{
		WS:            h.rcvWndScale,
		TS:            true,
		TSVal:         h.ep.timestamp(),
		TSEcr:         h.ep.recentTS,
		SACKPermitted: bool(sackEnabled),
	}

	// Execute is also called in a listen context so we want to make sure we
	// only send the TS/SACK option when we received the TS/SACK in the
	// initial SYN.
	if h.state == handshakeSynRcvd {
		synOpts.TS = h.ep.sendTSOk
		synOpts.SACKPermitted = h.ep.sackPermitted && bool(sackEnabled)
	}
	sendSynTCP(&h.ep.route, h.ep.id, h.flags, h.iss, h.ackNum, h.rcvWnd, synOpts)
	for h.state != handshakeCompleted {
		switch index, _ := s.Fetch(true); index {
		case wakerForResend:
			timeOut *= 2
			if timeOut > 60*time.Second {
				return tcpip.ErrTimeout
			}
			rt.Reset(timeOut)
			sendSynTCP(&h.ep.route, h.ep.id, h.flags, h.iss, h.ackNum, h.rcvWnd, synOpts)

		case wakerForNotification:
			n := h.ep.fetchNotifications()
			if n&notifyClose != 0 {
				return tcpip.ErrAborted
			}
			if n&notifyDrain != 0 {
				for !h.ep.segmentQueue.empty() {
					s := h.ep.segmentQueue.dequeue()
					err := h.handleSegment(s)
					s.decRef()
					if err != nil {
						return err
					}
					if h.state == handshakeCompleted {
						return nil
					}
				}
				close(h.ep.drainDone)
				<-h.ep.undrain
			}

		case wakerForNewSegment:
			if err := h.processSegments(); err != nil {
				return err
			}
		}
	}

	return nil
}
1196351
func (p *insertPlan) Execute(ctx context.Context) (*table.Table, error) {
	t, err := table.New([]string{})
	if err != nil {
		return nil, err
	}
	return t, update(ctx, p.stm.Data(), p.stm.OutputGraphNames(), p.store, func(g storage.Graph, d []*triple.Triple) error {
		tracer.Trace(p.tracer, func() []string {
			return []string{"Inserting triples to graph \"" + g.ID(ctx) + "\""}
		})
		return g.AddTriples(ctx, d)
	})
}
730938
func (c *Cluster) Execute(command Command) error {
	if command == nil {
		return ErrClusterCommandRequired
	}
	async := &Async{
		Command: command,
	}
	c.execute(async)
	if async.Error != nil {
		return async.Error
	}
	if cerr := command.Error(); cerr != nil {
		return cerr
	}
	return nil
}
477633
func (c *Cluster) Execute(cmd *Command) (*Reply, error) {
	if len(cmd.args) < 1 {
		return nil, ErrNoKey
	}
	key := string(convertString(cmd.args[0]))
	pool := c.shards[DefaultShardStrategy(key, len(c.shards))]
	conn, err := pool.Acquire()
	if err != nil {
		return nil, err
	}
	if conn == nil {
		return nil, ErrNotConnected
	}
	defer pool.Release(conn)
	return cmd.Run(conn)
}
1206165
func (f InterpreterFunc) Execute(s string, ctx *Context) (interface{}, error) {
	return f(s, ctx)
}
988560
func (e *HashAggExec) execute(ctx context.Context) (err error) {
	inputIter := chunk.NewIterator4Chunk(e.childResult)
	for {
		err := e.children[0].Next(ctx, chunk.NewRecordBatch(e.childResult))
		if err != nil {
			return err
		}

		failpoint.Inject("unparallelHashAggError", func(val failpoint.Value) {
			if val.(bool) {
				failpoint.Return(errors.New("HashAggExec.unparallelExec error"))
			}
		})

		// no more data.
		if e.childResult.NumRows() == 0 {
			return nil
		}
		for row := inputIter.Begin(); row != inputIter.End(); row = inputIter.Next() {
			groupKey, err := e.getGroupKey(row)
			if err != nil {
				return err
			}
			if !e.groupSet.Exist(groupKey) {
				e.groupSet.Insert(groupKey)
				e.groupKeys = append(e.groupKeys, groupKey)
			}
			partialResults := e.getPartialResults(groupKey)
			for i, af := range e.PartialAggFuncs {
				err = af.UpdatePartialResult(e.ctx, []chunk.Row{row}, partialResults[i])
				if err != nil {
					return err
				}
			}
		}
	}
}
740082
func (command *ServerCommand) Execute() error {
	var apiDocsDir string

	log.Infof("Generating a %v server", command.Language)

	if !command.NoAPIDocs {
		apiDocsDir = "apidocs"
	}

	cs := codegen.Server{
		RAMLFile:       command.RamlFile,
		Kind:           command.Kind,
		Dir:            command.Dir,
		PackageName:    command.PackageName,
		Lang:           command.Language,
		APIDocsDir:     apiDocsDir,
		RootImportPath: command.ImportPath,
		WithMain:       !command.NoMainGeneration,
		LibRootURLs:    strings.Split(command.LibRootURLs, ","),
	}
	return cs.Generate()
}
410317
func (rc *runCommands) Execute(state State) (*State, error) {
	logger.Tracef("run commands: %s", rc)
	if err := rc.callbacks.SetExecutingStatus("running commands"); err != nil {
		return nil, errors.Trace(err)
	}

	response, err := rc.runner.RunCommands(rc.args.Commands)
	switch err {
	case context.ErrRequeueAndReboot:
		logger.Warningf("cannot requeue external commands")
		fallthrough
	case context.ErrReboot:
		rc.sendResponse(response, nil)
		err = ErrNeedsReboot
	default:
		rc.sendResponse(response, err)
	}
	return nil, err
}
686280
func (c *Connection) Execute(ex *ExecuteRequest) (*ExecuteResponse, error) {
	c.dbMu.RLock()
	defer c.dbMu.RUnlock()
	if c.db == nil {
		return nil, ErrConnectionDoesNotExist
	}
	return c.store.execute(c, ex)
}
922182
func (m *SqlVm) Execute(writeContext datasource.ContextWriter, readContext datasource.ContextReader) (err error) {

	switch m.Keyword {
	case lex.TokenSelect:
		return m.ExecuteSelect(writeContext, readContext)
	case lex.TokenInsert:
		if rowWriter, ok := writeContext.(datasource.RowWriter); ok {
			return m.ExecuteInsert(rowWriter)
		} else {
			return fmt.Errorf("Must implement RowWriter: %T", writeContext)
		}
	case lex.TokenDelete:
		return m.ExecuteDelete(writeContext, readContext)
	default:
		u.Warnf("not implemented: %v", m.Keyword)
		return fmt.Errorf("not implemented %v", m.Keyword)
	}
	return nil
}
1238753
func (c *ScopeList) Execute(args []string) error {
	client, err := c.makeClient()
	if err != nil {
		return errors.Wrap(err, "could not make client")
	}
	defer shutdownMDClient(client)

	var scopes []string
	if scopes, err = c.getScopes(client); err == nil {
		return err
	}
	for _, sp := range scopes {
		fmt.Println(sp)
	}
	return nil
}
382396
func (c *SocketConnection) Execute(command, args string, sync bool) (m *Message, err error) {
	return c.SendMsg(map[string]string{
		"call-command":     "execute",
		"execute-app-name": command,
		"execute-app-arg":  args,
		"event-lock":       strconv.FormatBool(sync),
	}, "", "")
}
344745
func (pc *EndorsersCmd) Execute(conf common.Config) error {
	if pc.channel == nil || *pc.channel == "" {
		return errors.New("no channel specified")
	}

	if pc.server == nil || *pc.server == "" {
		return errors.New("no server specified")
	}

	server := *pc.server
	channel := *pc.channel

	ccAndCol := &chaincodesAndCollections{
		Chaincodes:  pc.chaincodes,
		Collections: pc.collections,
	}
	cc2collections, err := ccAndCol.parseInput()
	if err != nil {
		return err
	}

	var ccCalls []*ChaincodeCall

	for _, cc := range *ccAndCol.Chaincodes {
		ccCalls = append(ccCalls, &ChaincodeCall{
			Name:            cc,
			CollectionNames: cc2collections[cc],
		})
	}

	req, err := discovery.NewRequest().OfChannel(channel).AddEndorsersQuery(&ChaincodeInterest{Chaincodes: ccCalls})
	if err != nil {
		return errors.Wrap(err, "failed creating request")
	}

	res, err := pc.stub.Send(server, conf, req)
	if err != nil {
		return err
	}

	return pc.parser.ParseResponse(channel, res)
}
1100445
func Execute() {
	if err := FusisCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}
1258735
func (p *ServerCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
	c.Conf.Debug = p.debug
	c.Conf.Quiet = p.quiet
	log.SetLogger(p.logDir, c.Conf.Quiet, c.Conf.Debug, p.logJSON)

	c.Conf.DebugSQL = p.debugSQL
	c.Conf.Bind = p.bind
	c.Conf.Port = p.port
	c.Conf.DBPath = p.dbpath
	c.Conf.DBType = p.dbtype

	if !c.Conf.Validate() {
		return subcommands.ExitUsageError
	}

	driver, locked, err := db.NewDB(c.Conf.DBType, c.Conf.DBPath, c.Conf.DebugSQL)
	if err != nil {
		if locked {
			log.Errorf("Failed to Open DB. Close DB connection: %s", err)
			return subcommands.ExitFailure
		}
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	defer driver.CloseDB()

	var count int
	if count, err = driver.CountNvd(); err != nil {
		log.Errorf("Failed to count NVD table: %s", err)
		return subcommands.ExitFailure
	}

	if count == 0 {
		log.Infof("No Vulnerability data found. Run the below command to fetch data from NVD")
		log.Infof("")
		log.Infof(" for i in `seq 2002 $(date +\"%%Y\")`; do go-cve-dictionary fetchnvd -years $i ; done")
		log.Infof("")
		return subcommands.ExitSuccess
	}

	log.Infof("Starting HTTP Server...")
	if err = server.Start(p.logDir, driver); err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	return subcommands.ExitSuccess
}
1330549
func (c *QueryRead) Execute(args []string) error {
	return c.doQueryOp(ShellQueryClient.Read, c.Args.EntityName, c.Args.Queries, 1)
}
1072270
func (s *Script) Execute(conn *Conn, keyCount int, keysAndArgs ...interface{}) (*Reply, error) {
	s.lock.RLock()
	defer s.lock.RUnlock()
	if s.body == "" {
		return nil, ErrEmptyScript
	}
	args := make([]interface{}, len(keysAndArgs)+2)
	args[0] = s.sha
	args[1] = keyCount
	for i := range keysAndArgs {
		args[i+2] = keysAndArgs[i]
	}
	rep, err := NewCommand("EVALSHA", args...).Run(conn)
	if err != nil {
		return nil, err
	}
	if !rep.IsError() {
		return rep, nil
	}
	errorMessage, _ := rep.Error()
	if !strings.HasPrefix(errorMessage, "NOSCRIPT") {
		return rep, nil
	}
	args[0] = s.body
	return NewCommand("EVAL", args...).Run(conn)
}