// Noop keeps a session alive.
559808
func (c *Client) Noop() (err error) {
	res := struct {
		Status string `xmlrpc:"status"`
	}{}
	err = c.Call("NoOperation", []interface{}{c.Token}, &res)
	if err == nil && res.Status != StatusSuccess {
		err = fmt.Errorf("NoOp: %s", res.Status)
	}
	return
}
331128
func (p *Proxy) gRPCStop() {
	if p.grpcServer == nil {
		return
	}

	done := make(chan struct{})
	go func() {
		p.grpcServer.GracefulStop()
		close(done)
	}()

	select {
	case <-done:
		return
	case <-time.After(10 * time.Second):
		log.Info("Force-stopping the gRPC server after waiting for a graceful shutdown")
		p.grpcServer.Stop()
	}
}
1341760
func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error {
	// Use an stop channel to allow graceful shutdown without dropping audit events
	// after http server shutdown.
	auditStopCh := make(chan struct{})

	// Start the audit backend before any request comes in. This means we must call Backend.Run
	// before http server start serving. Otherwise the Backend.ProcessEvents call might block.
	if s.AuditBackend != nil {
		if err := s.AuditBackend.Run(auditStopCh); err != nil {
			return fmt.Errorf("failed to run the audit backend: %v", err)
		}
	}

	// Use an internal stop channel to allow cleanup of the listeners on error.
	internalStopCh := make(chan struct{})
	var stoppedCh <-chan struct{}
	if s.SecureServingInfo != nil && s.Handler != nil {
		var err error
		stoppedCh, err = s.SecureServingInfo.Serve(s.Handler, s.ShutdownTimeout, internalStopCh)
		if err != nil {
			close(internalStopCh)
			return err
		}
	}

	// Now that listener have bound successfully, it is the
	// responsibility of the caller to close the provided channel to
	// ensure cleanup.
	go func() {
		<-stopCh
		close(internalStopCh)
		if stoppedCh != nil {
			<-stoppedCh
		}
		s.HandlerChainWaitGroup.Wait()
		close(auditStopCh)
	}()

	s.RunPostStartHooks(stopCh)

	if _, err := systemd.SdNotify(true, "READY=1\n"); err != nil {
		klog.Errorf("Unable to send systemd daemon successful start message: %v\n", err)
	}

	return nil
}
937581
func (g *Gui) MainLoop() error {
	go func() {
		for {
			g.tbEvents <- termbox.PollEvent()
		}
	}()

	inputMode := termbox.InputAlt
	if g.InputEsc {
		inputMode = termbox.InputEsc
	}
	if g.Mouse {
		inputMode |= termbox.InputMouse
	}
	termbox.SetInputMode(inputMode)

	if err := g.flush(); err != nil {
		return err
	}
	for {
		select {
		case ev := <-g.tbEvents:
			if err := g.handleEvent(&ev); err != nil {
				return err
			}
		case ev := <-g.userEvents:
			if err := ev.f(g); err != nil {
				return err
			}
		}
		if err := g.consumeevents(); err != nil {
			return err
		}
		if err := g.flush(); err != nil {
			return err
		}
	}
}
1150615
func AddOp(bin *Bin) *Operation {
	return &Operation{opType: _ADD, binName: bin.Name, binValue: bin.Value}
}
26802
func (nsLife_) destroyOp(entities mongo.Collection, docID string, update bson.D) (txn.Op, error) {
	op, err := nsLife.aliveOp(entities, docID)
	if err != nil {
		return txn.Op{}, errors.Trace(err)
	}
	setDying := bson.D{{"$set", bson.D{{"life", Dying}}}}
	op.Update = append(setDying, update...)
	return op, nil
}
359873
func (s *session) close() error {
	s.closeOnce.Do(func() {
		s.cancel()
		if s.conn != nil {
			s.conn.Close(false)
		}
		close(s.closed)
	})

	return nil
}
519792
func (o *oplogDoc) validOp(ns string) bool {
	return ns == o.Ns && (o.Op == "i" || o.Op == "d" || o.Op == "u")
}
562611
func (r *actionsResolver) NextOp(
	localState resolver.LocalState,
	remoteState remotestate.Snapshot,
	opFactory operation.Factory,
) (operation.Operation, error) {
	// If there are no operation left to be run, then we cannot return the
	// error signaling such here, we must first check to see if an action is
	// already running (that has been interrupted) before we declare that
	// there is nothing to do.
	nextAction, err := nextAction(remoteState.Actions, localState.CompletedActions)
	if err != nil && err != resolver.ErrNoOperation {
		return nil, err
	}
	switch localState.Kind {
	case operation.RunHook:
		// We can still run actions if the unit is in a hook error state.
		if localState.Step == operation.Pending && err == nil {
			return opFactory.NewAction(nextAction)
		}
	case operation.RunAction:
		if localState.Hook != nil {
			logger.Infof("found incomplete action %v; ignoring", localState.ActionId)
			logger.Infof("recommitting prior %q hook", localState.Hook.Kind)
			return opFactory.NewSkipHook(*localState.Hook)
		} else {
			logger.Infof("%q hook is nil", operation.RunAction)

			// If the next action is the same as what the uniter is
			// currently running then this means that the uniter was
			// some how interrupted (killed) when running the action
			// and before updating the remote state to indicate that
			// the action was completed. The only safe thing to do
			// is fail the action, since rerunning an arbitrary
			// command can potentially be hazardous.
			if nextAction == *localState.ActionId {
				return opFactory.NewFailAction(*localState.ActionId)
			}

			// If the next action is different then what the uniter
			// is currently running, then the uniter may have been
			// interrupted while running the action but the remote
			// state was updated. Thus, the semantics of
			// (re)preparing the running operation should move the
			// uniter's state along safely. Thus, we return the
			// running action.
			return opFactory.NewAction(*localState.ActionId)
		}
	case operation.Continue:
		if err != resolver.ErrNoOperation {
			return opFactory.NewAction(nextAction)
		}
	}
	return nil, resolver.ErrNoOperation
}
1310412
func (g *Noop) Cmd(ctx context.Context, name string, args ...string) error {
	return nil
}
2731
func (conn *VTGateConn) Session(targetString string, options *querypb.ExecuteOptions) *VTGateSession {
	return &VTGateSession{
		session: &vtgatepb.Session{
			TargetString: targetString,
			Options:      options,
			Autocommit:   true,
		},
		impl: conn.impl,
	}
}
1274807
func (c *asyncClient) Blpop(arg0 string, timeout int) (result FutureBytesArray, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(fmt.Sprint(timeout))

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&BLPOP, [][]byte{arg0bytes, arg1bytes})
	if err == nil {
		result = resp.future.(FutureBytesArray)
	}
	return result, err

}
1300598
func (ftp *FTP) Noop() (err error) {
	_, err = ftp.cmd(StatusOK, "NOOP")
	return
}
724052
func fetchOp(c context.Context, wrappedOpID string) (*upload.Operation, error) {
	opID, err := upload.UnwrapOpID(c, wrappedOpID, auth.CurrentIdentity(c))
	if err != nil {
		if transient.Tag.In(err) {
			return nil, errors.Annotate(err, "failed to check HMAC on upload_operation_id").Err()
		}
		return nil, errors.Reason("no such upload operation").
			InternalReason("HMAC check failed - %s", err).
			Tag(grpcutil.NotFoundTag).Err()
	}

	op := &upload.Operation{ID: opID}
	switch err := datastore.Get(c, op); {
	case err == datastore.ErrNoSuchEntity:
		return nil, errors.Reason("no such upload operation").
			Tag(grpcutil.NotFoundTag).Err()
	case err != nil:
		return nil, errors.Annotate(err, "failed to fetch the upload operation").
			Tag(grpcutil.InternalTag).Err()
	}

	return op, nil
}
30886
func (s *Session) Close(optArgs ...CloseOpts) error {
	s.mu.Lock()
	defer s.mu.Unlock()

	if s.closed {
		return nil
	}

	if len(optArgs) >= 1 {
		if optArgs[0].NoReplyWait {
			s.mu.Unlock()
			s.NoReplyWait()
			s.mu.Lock()
		}
	}

	if s.cluster != nil {
		return s.cluster.Close()
	}
	s.cluster = nil
	s.closed = true

	return nil
}
267181
func (_class SessionClass) Logout(sessionID SessionRef) (_err error) {
	_method := "session.logout"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg)
	return
}
387341
func (c *Collection) writeOp(op interface{}, ordered bool) (lerr *LastError, err error) {
	s := c.Database.Session
	socket, err := s.acquireSocket(c.Database.Name == "local")
	if err != nil {
		return nil, err
	}
	defer socket.Release()

	s.m.RLock()
	safeOp := s.safeOp
	bypassValidation := s.bypassValidation
	s.m.RUnlock()

	if socket.ServerInfo().MaxWireVersion >= 2 {
		// Servers with a more recent write protocol benefit from write commands.
		if op, ok := op.(*insertOp); ok && len(op.documents) > 1000 {
			var errors []error
			// Maximum batch size is 1000. Must split out in separate operations for compatibility.
			all := op.documents
			for i := 0; i < len(all); i += 1000 {
				l := i + 1000
				if l > len(all) {
					l = len(all)
				}
				op.documents = all[i:l]
				lerr, err := c.writeOpCommand(socket, safeOp, op, ordered, bypassValidation)
				if err != nil {
					errors = append(errors, lerr.errors...)
					if op.flags&1 == 0 {
						return &LastError{errors: errors}, err
					}
				}
			}
			if len(errors) == 0 {
				return nil, nil
			}
			return &LastError{errors: errors}, errors[0]
		}
		return c.writeOpCommand(socket, safeOp, op, ordered, bypassValidation)
	} else if updateOps, ok := op.(bulkUpdateOp); ok {
		var lerr LastError
		for _, updateOp := range updateOps {
			oplerr, err := c.writeOpQuery(socket, safeOp, updateOp, ordered)
			if err != nil {
				lerr.N += oplerr.N
				lerr.modified += oplerr.modified
				lerr.errors = append(lerr.errors, oplerr.errors...)
				if ordered {
					break
				}
			}
		}
		if len(lerr.errors) == 0 {
			return nil, nil
		}
		return &lerr, lerr.errors[0]
	} else if deleteOps, ok := op.(bulkDeleteOp); ok {
		var lerr LastError
		for _, deleteOp := range deleteOps {
			oplerr, err := c.writeOpQuery(socket, safeOp, deleteOp, ordered)
			if err != nil {
				lerr.N += oplerr.N
				lerr.modified += oplerr.modified
				lerr.errors = append(lerr.errors, oplerr.errors...)
				if ordered {
					break
				}
			}
		}
		if len(lerr.errors) == 0 {
			return nil, nil
		}
		return &lerr, lerr.errors[0]
	}
	return c.writeOpQuery(socket, safeOp, op, ordered)
}