From e99baf766b7f210d04ce79589a4b95f262930774 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Sat, 5 Mar 2016 19:18:17 -0800 Subject: [PATCH] RetentionJoin() could block if scanner never started --- CHANGELOG.md | 6 +++++- smtpd/retention.go | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0733183..89f7fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [1.1.0-rc1] +## [Unreleased] +### Fixed +- Shutdown hang in retention scanner + +## [1.1.0-rc1] - 2016-03-04 ### Added - Inbucket now builds with Go 1.5 or 1.6 - Project can build & run inside a Docker container diff --git a/smtpd/retention.go b/smtpd/retention.go index ea3642c..9331233 100644 --- a/smtpd/retention.go +++ b/smtpd/retention.go @@ -133,8 +133,10 @@ func doRetentionScan(ds DataStore, maxAge time.Duration, sleep time.Duration) er // RetentionJoin does not retun until the retention scanner has shut down func RetentionJoin() { - select { - case _ = <-retentionShutdown: + if retentionShutdown != nil { + select { + case _ = <-retentionShutdown: + } } }