pin / tftp

TFTP server and client library for Golang
MIT License
287 stars 71 forks source link

Make Shutdown blocking to ensure outstanding requests completion #92

Closed pin closed 10 months ago

pin commented 10 months ago

Main change is in server Shutdown method semantics: upon call Serve (or LintenAndServe will exit immediately but Shutdown will block until all outstanding transfers are completed or timed out.

Hopefully it is effectively unnoticeable change for downstream code, but allows more straight-forward code, when Serve called in goroutine as e.g.:

go s.Serve(conn)

This become similar to Golang HTTP server shutdown logic.

Fixes #87

TestHookSuccess runs one request and check that hook was called. That test its flaky because server exits before goroutine executes a hook.

This change makes Shutdown blocking so when it completes the server is stopped all operations.