1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

Merge pull request #1013 from wuxiangzhou2010/master

add nil check  and correct some comments
This commit is contained in:
DarienRaymond 2018-04-03 11:52:58 +02:00 committed by GitHub
commit 8bc20c8656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 15 deletions

View File

@ -44,12 +44,12 @@ func NewDefaultDispatcher(ctx context.Context, config *Config) (*DefaultDispatch
return d, nil
}
// Start implements app.Application.
// Start implements common.Runnable.
func (*DefaultDispatcher) Start() error {
return nil
}
// Close implements app.Application.
// Close implements common.Closable.
func (*DefaultDispatcher) Close() error { return nil }
func getStatsName(u *protocol.User) string {

View File

@ -80,7 +80,7 @@ func (s *Server) Start() error {
return s.task.Start()
}
// Close implements common.Runnable.
// Close implements common.Closable.
func (s *Server) Close() error {
return s.task.Close()
}

View File

@ -11,7 +11,7 @@ import (
"v2ray.com/core/common/log"
)
// Instance is an app.Application that handles logs.
// Instance is a log.Handler that handles logs.
type Instance struct {
sync.RWMutex
config *Config
@ -91,7 +91,7 @@ func (g *Instance) startInternal() error {
return nil
}
// Start implements app.Application.Start().
// Start implements common.Runnable.Start().
func (g *Instance) Start() error {
if err := g.startInternal(); err != nil {
return err
@ -125,7 +125,7 @@ func (g *Instance) Handle(msg log.Message) {
}
}
// Close implement app.Application.Close().
// Close implements common.Closable.Close().
func (g *Instance) Close() error {
newError("Logger closing").AtDebug().WriteToLog()

View File

@ -43,12 +43,12 @@ func (m *Instance) ForLevel(level uint32) core.Policy {
return core.DefaultPolicy()
}
// Start implements app.Application.Start().
// Start implements common.Runnable.Start().
func (m *Instance) Start() error {
return nil
}
// Close implements app.Application.Close().
// Close implements common.Closable.Close().
func (m *Instance) Close() error {
return nil
}

View File

@ -133,7 +133,7 @@ func (h *Handler) Start() error {
return nil
}
// Close implements common.Runnable.
// Close implements common.Closable.
func (h *Handler) Close() error {
common.Close(h.mux)
return nil

View File

@ -50,7 +50,7 @@ func (t *PeriodicTask) Start() error {
return nil
}
// Close implements common.Runnable.
// Close implements common.Closable.
func (t *PeriodicTask) Close() error {
t.access.Lock()
defer t.access.Unlock()

View File

@ -26,7 +26,7 @@ type OutboundHandler interface {
Dispatch(ctx context.Context, outboundRay ray.OutboundRay)
}
// InboundHandlerManager is a feature that managers InboundHandlers.
// InboundHandlerManager is a feature that manages InboundHandlers.
type InboundHandlerManager interface {
Feature
// GetHandlers returns an InboundHandler for the given tag.
@ -98,7 +98,7 @@ func (m *syncInboundHandlerManager) Set(manager InboundHandlerManager) {
// OutboundHandlerManager is a feature that manages OutboundHandlers.
type OutboundHandlerManager interface {
Feature
// GetHandler returns an OutboundHandler will given tag.
// GetHandler returns an OutboundHandler for the given tag.
GetHandler(tag string) OutboundHandler
// GetDefaultHandler returns the default OutboundHandler. It is usually the first OutboundHandler specified in the configuration.
GetDefaultHandler() OutboundHandler

View File

@ -64,8 +64,14 @@ func (s *syncStatManager) GetCounter(name string) StatCounter {
}
func (s *syncStatManager) Set(m StatManager) {
if m == nil {
return
}
s.Lock()
defer s.Unlock()
if s.StatManager != nil {
s.StatManager.Close()
}
s.StatManager = m
}

View File

@ -123,7 +123,7 @@ func (c *connection) SetReadDeadline(t time.Time) error {
return nil
}
// SetWriteDeadline implement net.Conn.SetWriteDeadline().
// SetWriteDeadline implements net.Conn.SetWriteDeadline().
func (c *connection) SetWriteDeadline(t time.Time) error {
return nil
}

View File

@ -38,7 +38,7 @@ type Instance struct {
// New returns a new V2Ray instance based on given configuration.
// The instance is not started at this point.
// To make sure V2Ray instance works properly, the config must contain one Dispatcher, one InboundHandlerManager and one OutboundHandlerManager. Other features are optional.
// To ensure V2Ray instance works properly, the config must contain one Dispatcher, one InboundHandlerManager and one OutboundHandlerManager. Other features are optional.
func New(config *Config) (*Instance, error) {
var server = &Instance{
id: uuid.New(),
@ -169,7 +169,7 @@ func (s *Instance) allFeatures() []Feature {
}
// GetFeature returns a feature that was registered in this Instance. Nil if not found.
// The returned Feature must implement common.HasType and whose type equals the given feature type.
// The returned Feature must implement common.HasType and whose type equals to the given feature type.
func (s *Instance) GetFeature(featureType interface{}) Feature {
for _, f := range s.features {
if hasType, ok := f.(common.HasType); ok {