MCPcopy
hub / github.com/safing/portmaster / selfcheckTaskFunc

Function selfcheckTaskFunc

service/compat/module.go:107–151  ·  view source on GitHub ↗
(wc *mgr.WorkerCtx)

Source from the content-addressed store, hash-verified

105}
106
107func selfcheckTaskFunc(wc *mgr.WorkerCtx) error {
108
109 // Create tracing logger.
110 ctx, tracer := log.AddTracer(wc.Ctx())
111 defer tracer.Submit()
112 tracer.Tracef("compat: running self-check")
113
114 // Run selfcheck and return if successful.
115 issue, err := selfcheck(ctx)
116 switch {
117 case err == nil:
118 // Successful.
119 tracer.Debugf("compat: self-check successful")
120 case errors.Is(err, errSelfcheckSkipped):
121 // Skipped.
122 tracer.Debugf("compat: %s", err)
123 case issue == nil:
124 // Internal error.
125 tracer.Warningf("compat: %s", err)
126 case selfcheckNetworkChangedFlag.IsSet():
127 // The network changed, ignore the issue.
128 default:
129 // The self-check failed.
130
131 // Set state and increase counter.
132 selfCheckIsFailing.Set()
133 selfcheckFails++
134
135 // Log and notify.
136 tracer.Errorf("compat: %s", err)
137 if selfcheckFails >= selfcheckFailThreshold {
138 issue.notify(err)
139 }
140
141 // Retry quicker when failed.
142 module.selfcheckWorkerMgr.Delay(selfcheckTaskRetryAfter)
143
144 return nil
145 }
146
147 // Reset self-check state.
148 resetSelfCheckState()
149
150 return nil
151}
152
153func resetSelfCheckState() {
154 selfcheckNetworkChangedFlag.Refresh()

Callers

nothing calls this directly

Calls 14

AddTracerFunction · 0.92
selfcheckFunction · 0.85
resetSelfCheckStateFunction · 0.85
TracefMethod · 0.80
DebugfMethod · 0.80
WarningfMethod · 0.80
ErrorfMethod · 0.80
CtxMethod · 0.65
SetMethod · 0.65
SubmitMethod · 0.45
IsMethod · 0.45
IsSetMethod · 0.45

Tested by

no test coverage detected