File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 "sort"
88 "strconv"
99 "strings"
10+ "sync"
1011 "text/template"
1112 "time"
1213)
@@ -23,6 +24,9 @@ var Instance proxy
2324
2425var reloadPause time.Duration = 1000
2526
27+ var certMu = & sync.Mutex {}
28+ var reloadMu = & sync.Mutex {}
29+
2630// TODO: Move to data from proxy.go when static (e.g. env. vars.)
2731type configData struct {
2832 CertsString string
@@ -143,6 +147,8 @@ func (m HaProxy) ReadConfig() (string, error) {
143147
144148// Reload HAProxy
145149func (m HaProxy ) Reload () error {
150+ reloadMu .Lock ()
151+ defer reloadMu .Unlock ()
146152 logPrintf ("Reloading the proxy" )
147153 var reloadErr error
148154 reconfigureAttempts := 20
@@ -332,8 +338,8 @@ func (m *HaProxy) getCertsConfigSnippet() string {
332338 h2 = "h2,"
333339 }
334340 certs = fmt .Sprintf (" ssl crt-list /cfg/crt-list.txt alpn %shttp/1.1" , h2 )
335- mu .Lock ()
336- defer mu .Unlock ()
341+ certMu .Lock ()
342+ defer certMu .Unlock ()
337343 writeFile ("/cfg/crt-list.txt" , []byte (strings .Join (certPaths , "\n " )), 0664 )
338344 }
339345 if len (os .Getenv ("CA_FILE" )) > 0 {
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
1212 "os/exec"
1313 "regexp"
1414 "strings"
15- "sync"
1615 "syscall"
1716 "time"
1817 "unicode"
@@ -142,5 +141,3 @@ func replaceNonAlphabetAndNumbers(value []string) string {
142141 reg , _ := regexp .Compile ("[^A-Za-z0-9]+" )
143142 return reg .ReplaceAllString (strings .Join (value , "_" ), "_" )
144143}
145-
146- var mu = & sync.Mutex {}
You can’t perform that action at this time.
0 commit comments