Browse Source

Merge pull request #461 from rod-hynes/master

Clear repetitive notice state on controller restarts
Rod Hynes 7 years ago
parent
commit
60bbabbe49
2 changed files with 14 additions and 0 deletions
  1. 5 0
      psiphon/controller.go
  2. 9 0
      psiphon/notice.go

+ 5 - 0
psiphon/controller.go

@@ -166,6 +166,11 @@ func NewController(config *Config) (controller *Controller, err error) {
 // component fails or the parent context is canceled.
 func (controller *Controller) Run(ctx context.Context) {
 
+	// Ensure fresh repetitive notice state for each run, so the
+	// client will always get an AvailableEgressRegions notice,
+	// an initial instance of any repetitive error notice, etc.
+	ResetRepetitiveNotices()
+
 	ReportAvailableRegions(controller.config)
 
 	runCtx, stopRunning := context.WithCancel(ctx)

+ 9 - 0
psiphon/notice.go

@@ -784,6 +784,15 @@ func outputRepetitiveNotice(
 	}
 }
 
+// ResetRepetitiveNotices resets the repetitive notice state, so
+// the next instance of any notice will not be supressed.
+func ResetRepetitiveNotices() {
+	repetitiveNoticeMutex.Lock()
+	defer repetitiveNoticeMutex.Unlock()
+
+	repetitiveNoticeStates = make(map[string]*repetitiveNoticeState)
+}
+
 type noticeObject struct {
 	NoticeType string          `json:"noticeType"`
 	Data       json.RawMessage `json:"data"`