Repository: traefik/traefik
File: pkg/server/server_entrypoint_udp.go (Go)

Code before:
		}

		log.Error().Str(logs.EntryPointName, epName).Msg("EntryPoint does not exist")
	}
}

// UDPEntryPoint is an entry point where we listen for UDP packets.
type UDPEntryPoint struct {
	listener               *udp.Listener
	switcher               *udp.HandlerSwitcher
	transportConfiguration *static.EntryPointsTransport
}

// NewUDPEntryPoint returns a UDP entry point.
func NewUDPEntryPoint(config *static.EntryPoint, name string) (*UDPEntryPoint, error) {
	var listener *udp.Listener
	var err error

	timeout := time.Duration(config.UDP.Timeout)

	// if we have predefined connections from socket activation
	if socketActivation.isEnabled() {
		if conn, err := socketActivation.getConn(name); err == nil {
			listener, err = udp.ListenPacketConn(conn, timeout)
			if err != nil {
				log.Warn().Str("name", name).Msgf("Unable to create socket activation listener: %v", err)
			}
		} else {
			log.Warn().Str("name", name).Msgf("Unable to use socket activation for entrypoint: %v", err)
		}
	}

	if listener == nil {
		listenConfig := newListenConfig(config)
		listener, err = udp.Listen(listenConfig, "udp", config.GetAddress(), timeout)
		if err != nil {
			return nil, fmt.Errorf("error creating listener: %w", err)
		}
	}

	return &UDPEntryPoint{listener: listener, switcher: &udp.HandlerSwitcher{}, transportConfiguration: config.Transport}, nil
}

// Start commences the listening for ep.
func (ep *UDPEntryPoint) Start(ctx context.Context) {
	log.Ctx(ctx).Debug().Msg("Start UDP Server")
	for {
		conn, err := ep.listener.Accept()
		if err != nil {
			// Only errClosedListener can happen that's why we return
			return

Review comment (suggestion):
```suggestion
				log.Warn().Err(err).Str("name", name).Msg("Unable to create socket activation listener")
```

Code after:
		}

		log.Error().Str(logs.EntryPointName, epName).Msg("EntryPoint does not exist")
	}
}

// UDPEntryPoint is an entry point where we listen for UDP packets.
type UDPEntryPoint struct {
	listener               *udp.Listener
	switcher               *udp.HandlerSwitcher
	transportConfiguration *static.EntryPointsTransport
}

// NewUDPEntryPoint returns a UDP entry point.
func NewUDPEntryPoint(config *static.EntryPoint, name string) (*UDPEntryPoint, error) {
	var listener *udp.Listener
	var err error

	timeout := time.Duration(config.UDP.Timeout)

	// if we have predefined connections from socket activation
	if socketActivation.isEnabled() {
		if conn, err := socketActivation.getConn(name); err == nil {
			listener, err = udp.ListenPacketConn(conn, timeout)
			if err != nil {
				log.Warn().Err(err).Str("name", name).Msg("Unable to create socket activation listener")
			}
		} else {
			log.Warn().Err(err).Str("name", name).Msg("Unable to use socket activation for entrypoint")
		}
	}

	if listener == nil {
		listenConfig := newListenConfig(config)
		listener, err = udp.Listen(listenConfig, "udp", config.GetAddress(), timeout)
		if err != nil {
			return nil, fmt.Errorf("error creating listener: %w", err)
		}
	}

	return &UDPEntryPoint{listener: listener, switcher: &udp.HandlerSwitcher{}, transportConfiguration: config.Transport}, nil
}

// Start commences the listening for ep.
func (ep *UDPEntryPoint) Start(ctx context.Context) {
	log.Ctx(ctx).Debug().Msg("Start UDP Server")
	for {
		conn, err := ep.listener.Accept()
		if err != nil {
			// Only errClosedListener can happen that's why we return
			return