mailgun / mailgun-go

Go library for sending mail with the Mailgun API.
BSD 3-Clause "New" or "Revised" License
700 stars 143 forks source link

Fix resource leak from time.NewTicker #313

Closed SamuelSarle closed 12 months ago

SamuelSarle commented 1 year ago

Currently resources are leaked when EventPoller.Poll() returns from the <-ctx.Done() branch of the select because a time.Ticker must be stopped to release associated resources.

This PR fixes the issue by adding a .Stop() call on the branch. The time.Ticker is also switched to a time.Timer since only one event is used and time.Timer is more suitable. Alternatively, it would be enough to just add a .Stop() call for time.Ticker.