Преглед изворни кода

Fix: clear repetitive notice state on controller restarts

Rod Hynes пре 7 година
родитељ
комит
d3ecb2310e
2 измењених фајлова са 11 додато и 0 уклоњено
  1. 2 0
      psiphon/controller.go
  2. 9 0
      psiphon/notice.go

+ 2 - 0
psiphon/controller.go

@@ -166,6 +166,8 @@ func NewController(config *Config) (controller *Controller, err error) {
 // component fails or the parent context is canceled.
 // component fails or the parent context is canceled.
 func (controller *Controller) Run(ctx context.Context) {
 func (controller *Controller) Run(ctx context.Context) {
 
 
+	ResetRepetitiveNotices()
+
 	ReportAvailableRegions(controller.config)
 	ReportAvailableRegions(controller.config)
 
 
 	runCtx, stopRunning := context.WithCancel(ctx)
 	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 {
 type noticeObject struct {
 	NoticeType string          `json:"noticeType"`
 	NoticeType string          `json:"noticeType"`
 	Data       json.RawMessage `json:"data"`
 	Data       json.RawMessage `json:"data"`