1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

server: resolve linter errors (#433)

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2023-11-13 11:34:05 -08:00
committed by GitHub
parent e22ed26633
commit 535438342e
5 changed files with 15 additions and 20 deletions

View File

@@ -45,7 +45,7 @@ func TestNoTLS(t *testing.T) {
t.Fatalf("Failed to send CAPA; %v.", err)
}
replies := []string{}
for true {
for {
reply, err := c.ReadLine()
if err != nil {
t.Fatalf("Reading CAPA line failed %v", err)
@@ -85,7 +85,7 @@ func TestStartTLS(t *testing.T) {
t.Fatalf("Failed to send CAPA; %v.", err)
}
replies := []string{}
for true {
for {
reply, err := c.ReadLine()
if err != nil {
t.Fatalf("Reading CAPA line failed %v", err)
@@ -138,7 +138,7 @@ func TestStartTLS(t *testing.T) {
if !strings.HasPrefix(reply, "+OK") {
t.Fatalf("CAPA failed: %s", reply)
}
for true {
for {
reply, err := c.ReadLine()
if err != nil {
t.Fatalf("Reading CAPA line failed %v", err)
@@ -188,7 +188,7 @@ func TestForceTLS(t *testing.T) {
if !strings.HasPrefix(reply, "+OK") {
t.Fatalf("CAPA failed: %s", reply)
}
for true {
for {
reply, err := c.ReadLine()
if err != nil {
t.Fatalf("Reading CAPA line failed %v", err)

View File

@@ -74,9 +74,7 @@ func (s *Server) Start(ctx context.Context, readyFunc func()) {
readyFunc()
// Wait for shutdown.
select {
case _ = <-ctx.Done():
}
<-ctx.Done()
slog = log.With().Str("module", "pop3").Str("phase", "shutdown").Logger()
slog.Debug().Msg("POP3 shutdown requested, connections will be drained")
@@ -92,8 +90,8 @@ func (s *Server) serve(ctx context.Context) {
var tempDelay time.Duration
for sid := 1; ; sid++ {
if conn, err := s.listener.Accept(); err != nil {
if nerr, ok := err.(net.Error); ok && nerr.Temporary() {
// Temporary error, sleep for a bit and try again.
if nerr, ok := err.(net.Error); ok && nerr.Timeout() {
// Timeout, sleep for a bit and try again.
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
@@ -103,7 +101,7 @@ func (s *Server) serve(ctx context.Context) {
tempDelay = max
}
log.Error().Str("module", "pop3").Err(err).
Msgf("POP3 accept error; retrying in %v", tempDelay)
Msgf("POP3 accept timout; retrying in %v", tempDelay)
time.Sleep(tempDelay)
continue
} else {

View File

@@ -547,7 +547,6 @@ func (s *Session) dataHandler() {
s.send("250 Mail accepted for delivery")
s.logger.Info().Msgf("Message size %v bytes", mailData.Len())
s.reset()
return
}
func (s *Session) enterState(state State) {

View File

@@ -147,8 +147,8 @@ func (s *Server) serve(ctx context.Context) {
for sessionID := 1; ; sessionID++ {
if conn, err := s.listener.Accept(); err != nil {
// There was an error accepting the connection.
if nerr, ok := err.(net.Error); ok && nerr.Temporary() {
// Temporary error, sleep for a bit and try again.
if nerr, ok := err.(net.Error); ok && nerr.Timeout() {
// Timeout, sleep for a bit and try again.
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
@@ -158,7 +158,7 @@ func (s *Server) serve(ctx context.Context) {
tempDelay = max
}
log.Error().Str("module", "smtp").Err(err).
Msgf("SMTP accept error; retrying in %v", tempDelay)
Msgf("SMTP accept timeout; retrying in %v", tempDelay)
time.Sleep(tempDelay)
continue
} else {

View File

@@ -159,11 +159,9 @@ func (s *Server) Start(ctx context.Context, readyFunc func()) {
readyFunc()
// Wait for shutdown
select {
case _ = <-ctx.Done():
log.Debug().Str("module", "web").Str("phase", "shutdown").
Msg("HTTP server shutting down on request")
}
<-ctx.Done()
log.Debug().Str("module", "web").Str("phase", "shutdown").
Msg("HTTP server shutting down on request")
// Closing the listener will cause the serve() go routine to exit
if err := listener.Close(); err != nil {
@@ -195,7 +193,7 @@ func (s *Server) serve(ctx context.Context) {
err := server.Serve(listener)
select {
case _ = <-ctx.Done():
case <-ctx.Done():
// Nop
default:
log.Error().Str("module", "web").Str("phase", "startup").Err(err).