"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/server/server_entrypoint_tcp.go" between
traefik-v2.3.2.src.tar.gz and traefik-v2.3.3.src.tar.gz

About: Traefik is a cloud native edge router, a reverse proxy and load balancer for HTTP and TCP-based applications.

server_entrypoint_tcp.go  (traefik-v2.3.2.src):server_entrypoint_tcp.go  (traefik-v2.3.3.src)
package server package server
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
stdlog "log" stdlog "log"
"net" "net"
"net/http" "net/http"
"sync" "sync"
"syscall"
"time" "time"
proxyprotocol "github.com/c0va23/go-proxyprotocol" proxyprotocol "github.com/c0va23/go-proxyprotocol"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/traefik/traefik/v2/pkg/config/static" "github.com/traefik/traefik/v2/pkg/config/static"
"github.com/traefik/traefik/v2/pkg/ip" "github.com/traefik/traefik/v2/pkg/ip"
"github.com/traefik/traefik/v2/pkg/log" "github.com/traefik/traefik/v2/pkg/log"
"github.com/traefik/traefik/v2/pkg/middlewares" "github.com/traefik/traefik/v2/pkg/middlewares"
"github.com/traefik/traefik/v2/pkg/middlewares/forwardedheaders" "github.com/traefik/traefik/v2/pkg/middlewares/forwardedheaders"
"github.com/traefik/traefik/v2/pkg/safe" "github.com/traefik/traefik/v2/pkg/safe"
skipping to change at line 175 skipping to change at line 177
// Start starts the TCP server. // Start starts the TCP server.
func (e *TCPEntryPoint) Start(ctx context.Context) { func (e *TCPEntryPoint) Start(ctx context.Context) {
logger := log.FromContext(ctx) logger := log.FromContext(ctx)
logger.Debugf("Start TCP Server") logger.Debugf("Start TCP Server")
for { for {
conn, err := e.listener.Accept() conn, err := e.listener.Accept()
if err != nil { if err != nil {
logger.Error(err) logger.Error(err)
if netErr, ok := err.(net.Error); ok && netErr.Temporary(
) { var netErr net.Error
if errors.As(err, &netErr) && netErr.Temporary() {
continue continue
} }
e.httpServer.Forwarder.errChan <- err e.httpServer.Forwarder.errChan <- err
e.httpsServer.Forwarder.errChan <- err e.httpsServer.Forwarder.errChan <- err
return return
} }
writeCloser, err := writeCloser(conn) writeCloser, err := writeCloser(conn)
if err != nil { if err != nil {
panic(err) panic(err)
} }
safe.Go(func() { safe.Go(func() {
// Enforce read/write deadlines at the connection level, // Enforce read/write deadlines at the connection level,
skipping to change at line 233 skipping to change at line 239
logger.Debugf("Waiting %s seconds before killing connections.", graceTime Out) logger.Debugf("Waiting %s seconds before killing connections.", graceTime Out)
var wg sync.WaitGroup var wg sync.WaitGroup
shutdownServer := func(server stoppableServer) { shutdownServer := func(server stoppableServer) {
defer wg.Done() defer wg.Done()
err := server.Shutdown(ctx) err := server.Shutdown(ctx)
if err == nil { if err == nil {
return return
} }
if ctx.Err() == context.DeadlineExceeded { if errors.Is(ctx.Err(), context.DeadlineExceeded) {
logger.Debugf("Server failed to shutdown within deadline because: %s", err) logger.Debugf("Server failed to shutdown within deadline because: %s", err)
if err = server.Close(); err != nil { if err = server.Close(); err != nil {
logger.Error(err) logger.Error(err)
} }
return return
} }
logger.Error(err) logger.Error(err)
// We expect Close to fail again because Shutdown most likely fai led when trying to close a listener. // We expect Close to fail again because Shutdown most likely fai led when trying to close a listener.
// We still call it however, to make sure that all connections ge t closed as well. // We still call it however, to make sure that all connections ge t closed as well.
server.Close() server.Close()
skipping to change at line 264 skipping to change at line 270
} }
if e.tracker != nil { if e.tracker != nil {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
err := e.tracker.Shutdown(ctx) err := e.tracker.Shutdown(ctx)
if err == nil { if err == nil {
return return
} }
if ctx.Err() == context.DeadlineExceeded { if errors.Is(ctx.Err(), context.DeadlineExceeded) {
logger.Debugf("Server failed to shutdown before d eadline because: %s", err) logger.Debugf("Server failed to shutdown before d eadline because: %s", err)
} }
e.tracker.Close() e.tracker.Close()
}() }()
} }
wg.Wait() wg.Wait()
cancel() cancel()
} }
skipping to change at line 343 skipping to change at line 349
tc, err := ln.AcceptTCP() tc, err := ln.AcceptTCP()
if err != nil { if err != nil {
return nil, err return nil, err
} }
if err = tc.SetKeepAlive(true); err != nil { if err = tc.SetKeepAlive(true); err != nil {
return nil, err return nil, err
} }
if err = tc.SetKeepAlivePeriod(3 * time.Minute); err != nil { if err = tc.SetKeepAlivePeriod(3 * time.Minute); err != nil {
return nil, err // Some systems, such as OpenBSD, have no user-settable per-socke
t TCP
// keepalive options.
if !errors.Is(err, syscall.ENOPROTOOPT) {
return nil, err
}
} }
return tc, nil return tc, nil
} }
type proxyProtocolLogger struct { type proxyProtocolLogger struct {
log.Logger log.Logger
} }
// Printf force log level to debug. // Printf force log level to debug.
 End of changes. 8 change blocks. 
5 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)