Skip to content

Commit

Permalink
chore: clean up unused code and deprecated function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Sep 21, 2024
1 parent b210186 commit 8c129ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eventloop_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (s *testServerGC) GC(secs int) {
runtime.GC()
gcTime := time.Since(now)
gcAllTime += gcTime
s.tester.Log(s.tester.Name(), s.network, " server gc:", gcTime, ", average gc time:", gcAllTime/gcAllCount)
s.tester.Log(s.tester.Name(), s.network, "server gc:", gcTime, "average gc time:", gcAllTime/gcAllCount)
if time.Since(gcStart) >= time.Second*time.Duration(secs) {
break
}
Expand Down
2 changes: 0 additions & 2 deletions gnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ type Socket interface {
// algorithm).
// The default is true (no delay), meaning that data is sent as soon as possible after a Write.
SetNoDelay(noDelay bool) error
// CloseRead() error
// CloseWrite() error
}

// Conn is an interface of underlying connection.
Expand Down
12 changes: 9 additions & 3 deletions gnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,15 @@ type testStopServer struct {
*BuiltinEventEngine
tester *testing.T
network, addr, protoAddr string
eng Engine
action bool
}

func (t *testStopServer) OnBoot(eng Engine) (action Action) {
t.eng = eng
return
}

func (t *testStopServer) OnClose(Conn, error) (action Action) {
logging.Debugf("closing connection...")
return
Expand Down Expand Up @@ -1237,7 +1243,7 @@ func (t *testStopServer) OnTick() (delay time.Duration, action Action) {
go func() {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
logging.Debugf("stop engine...", Stop(ctx, t.protoAddr))
logging.Debugf("stop engine...", t.eng.Stop(ctx))
}()

// waiting the engine shutdown.
Expand Down Expand Up @@ -1365,7 +1371,7 @@ type testClosedWakeUpServer struct {
clientClosed chan struct{}
}

func (s *testClosedWakeUpServer) OnBoot(_ Engine) (action Action) {
func (s *testClosedWakeUpServer) OnBoot(eng Engine) (action Action) {
go func() {
c, err := net.Dial(s.network, s.addr)
require.NoError(s.tester, err)
Expand All @@ -1380,7 +1386,7 @@ func (s *testClosedWakeUpServer) OnBoot(_ Engine) (action Action) {
close(s.clientClosed)
<-s.serverClosed

logging.Debugf("stop engine...", Stop(context.TODO(), s.protoAddr))
logging.Debugf("stop engine...", eng.Stop(context.TODO()))
}()

return None
Expand Down
2 changes: 0 additions & 2 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ var (
ErrUnsupportedUDPProtocol = errors.New("gnet: only udp/udp4/udp6 are supported")
// ErrUnsupportedUDSProtocol occurs when trying to use an unsupported Unix protocol.
ErrUnsupportedUDSProtocol = errors.New("gnet: only unix is supported")
// ErrUnsupportedPlatform occurs when running gnet on an unsupported platform.
ErrUnsupportedPlatform = errors.New("gnet: unsupported platform in gnet")
// ErrUnsupportedOp occurs when calling some methods that has not been implemented yet.
ErrUnsupportedOp = errors.New("gnet: unsupported operation")
// ErrNegativeSize occurs when trying to pass a negative size to a buffer.
Expand Down

0 comments on commit 8c129ae

Please sign in to comment.