// create a new TCP session buffer
329695
func newPcapSession(client string, logger logrus.FieldLogger) *pcapSession {
	return &pcapSession{
		client: client,
		logger: logger,
	}
}
121623
func (p *parserMixin) TCP() (target **net.TCPAddr) {
	target = new(*net.TCPAddr)
	p.TCPVar(target)
	return
}
46497
func NewTCPServer(uri string) (server *TCPServer) {
	if uri == "" {
		uri = "tcp://127.0.0.1:0"
	}
	server = new(TCPServer)
	server.initTCPService()
	server.starter.server = server
	server.uri = uri
	return
}
203961
func New(next http.Handler, setters ...optSetter) (*Buffer, error) {
	strm := &Buffer{
		next: next,

		maxRequestBodyBytes: DefaultMaxBodyBytes,
		memRequestBodyBytes: DefaultMemBodyBytes,

		maxResponseBodyBytes: DefaultMaxBodyBytes,
		memResponseBodyBytes: DefaultMemBodyBytes,

		log: log.StandardLogger(),
	}
	for _, s := range setters {
		if err := s(strm); err != nil {
			return nil, err
		}
	}
	if strm.errHandler == nil {
		strm.errHandler = errHandler
	}

	return strm, nil
}
817599
func (c *Client) CreateSession(ctx context.Context, user string) (*platform.Session, error) {
	var sess *platform.Session
	err := c.db.Update(func(tx *bolt.Tx) error {
		s, err := c.createSession(ctx, tx, user)
		if err != nil {
			return err
		}

		sess = s

		return nil
	})

	if err != nil {
		return nil, err
	}

	return sess, nil
}
166169
func (s *StdoutClient) CreateSocket() error {
	if s.FD == nil {
		s.FD = os.Stdout
	}
	return nil
}
1080562
func (s *Server) Create(ctx context.Context, q *SessionCreateRequest) (*SessionResponse, error) {
	if q.Token != "" {
		return nil, status.Errorf(codes.Unauthenticated, "token-based session creation no longer supported. please upgrade argocd cli to v0.7+")
	}
	if q.Username == "" || q.Password == "" {
		return nil, status.Errorf(codes.Unauthenticated, "no credentials supplied")
	}
	err := s.mgr.VerifyUsernamePassword(q.Username, q.Password)
	if err != nil {
		return nil, err
	}
	jwtToken, err := s.mgr.Create(q.Username, 0)
	if err != nil {
		return nil, err
	}
	return &SessionResponse{Token: jwtToken}, nil
}
440591
func (c *cmd) createSession() (string, error) {
	var id string
	var err error
	if c.conf.foreignDC {
		id, err = c.createSessionForeign()
	} else {
		id, err = c.createSessionLocal()
	}
	if err == nil {
		c.stopCh = make(chan struct{})
		go c.renewSession(id, c.stopCh)
	}
	return id, err
}
309064
func (auth *Auth) CreateSession(w http.ResponseWriter, user User) error {
	session := auth.sessions.Create(user)
	if !session.Exists() {
		return fmt.Errorf("auth: could not create new session")
	}
	SetCookie(w, auth.config.Cookie, session)
	return nil
}
691655
func (env *sessionEnviron) Create(ctx callcontext.ProviderCallContext, args environs.CreateParams) error {
	return env.ensureVMFolder(args.ControllerUUID, ctx)
}
881183
func (msc *MockStatsdClient) CreateSocket() error {
	if msc.CreateSocketFn == nil {
		return nil
	}
	return msc.CreateSocketFn()
}
1027240
func createWebSocketStreams(req *http.Request, w http.ResponseWriter, opts *Options, idleTimeout time.Duration) (*context, bool) {
	channels := createChannels(opts)
	conn := wsstream.NewConn(map[string]wsstream.ChannelProtocolConfig{
		"": {
			Binary:   true,
			Channels: channels,
		},
		preV4BinaryWebsocketProtocol: {
			Binary:   true,
			Channels: channels,
		},
		preV4Base64WebsocketProtocol: {
			Binary:   false,
			Channels: channels,
		},
		v4BinaryWebsocketProtocol: {
			Binary:   true,
			Channels: channels,
		},
		v4Base64WebsocketProtocol: {
			Binary:   false,
			Channels: channels,
		},
	})
	conn.SetIdleTimeout(idleTimeout)
	negotiatedProtocol, streams, err := conn.Open(httplog.Unlogged(w), req)
	if err != nil {
		runtime.HandleError(fmt.Errorf("Unable to upgrade websocket connection: %v", err))
		return nil, false
	}

	// Send an empty message to the lowest writable channel to notify the client the connection is established
	// TODO: make generic to SPDY and WebSockets and do it outside of this method?
	switch {
	case opts.Stdout:
		streams[stdoutChannel].Write([]byte{})
	case opts.Stderr:
		streams[stderrChannel].Write([]byte{})
	default:
		streams[errorChannel].Write([]byte{})
	}

	ctx := &context{
		conn:         conn,
		stdinStream:  streams[stdinChannel],
		stdoutStream: streams[stdoutChannel],
		stderrStream: streams[stderrChannel],
		tty:          opts.TTY,
		resizeStream: streams[resizeChannel],
	}

	switch negotiatedProtocol {
	case v4BinaryWebsocketProtocol, v4Base64WebsocketProtocol:
		ctx.writeStatus = v4WriteStatusFunc(streams[errorChannel])
	default:
		ctx.writeStatus = v1WriteStatusFunc(streams[errorChannel])
	}

	return ctx, true
}
1156803
func New(n int64) BufferAt {
	return &memory{
		N:      n,
		Buffer: bytes.NewBuffer(nil),
	}
}
349380
func New(address string, extra ...string) (*Pool, error) {
	pool := &redis.Pool{
		MaxIdle:     1024,
		MaxActive:   1024,
		IdleTimeout: 300 * time.Second,
		Wait:        true,
		Dial: func() (redis.Conn, error) {
			c, err := redis.Dial("tcp", address)
			if err != nil {
				return nil, err
			}
			return c, err
		},
		TestOnBorrow: func(c redis.Conn, t time.Time) error {
			_, err := c.Do("PING")
			return err
		},
	}

	return &Pool{redis: pool}, nil
}
1259026
func (lib *Lib) MakeBuffer(alloc int) (*Buffer, error) {
	s := C.malloc(C.gss_buffer_size)
	if s == nil {
		return nil, ErrMallocFailed
	}
	C.memset(s, 0, C.gss_buffer_size)

	b := &Buffer{
		Lib:            lib,
		C_gss_buffer_t: C.gss_buffer_t(s),
		alloc:          alloc,
	}
	return b, nil
}
74457
func CreateSession(info infoschema.InfoSchema) (Session, error) {
	s, err := createSession(info)
	if err != nil {
		return nil, errors.Trace(err)
	}

	return s, nil
}
840459
func newBuffer() *buffer {
	e := new(element)
	b := &buffer{
		Cond: newCond(),
		head: e,
		tail: e,
	}
	return b
}