GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Use mutex in FracFunctional to protect map access.

This should fix a race condition that we ran into in deployment:

    fatal error: concurrent map iteration and map write

    goroutine 98984 [running]:
    runtime.throw(0x95bb18, 0x26)
            /home/phw/sw/go/src/runtime/panic.go:1116 +0x72 fp=0xc0001735a8 sp=0xc000173578 pc=0x437e32
    runtime.mapiternext(0xc000173650)
            /home/phw/sw/go/src/runtime/map.go:853 +0x554 fp=0xc000173628 sp=0xc0001735a8 pc=0x412534
    main.(*TestCache).FracFunctional(0xc00016e960, 0xc00014a990)
            /home/phw/rcs/bridgestrap/cache.go:64 +0xbb fp=0xc0001736c0 sp=0xc000173628 pc=0x8610db
    main.(*TestCache).AddEntry(0xc00016e960, 0xc00031caa0, 0x98, 0x9dab00, 0xc00002e060, 0x13d5c8c, 0xed78148dc, 0x0)
            /home/phw/rcs/bridgestrap/cache.go:161 +0x17c fp=0xc000173730 sp=0xc0001736c0 pc=0x861c5c
    main.testBridgeLines(0xc00000f500, 0x1c)
parent 5a0e7d48
......@@ -56,6 +56,9 @@ func bridgeLineToAddrPort(bridgeLine string) (string, error) {
// are functional.
func (tc *TestCache) FracFunctional() float64 {
tc.l.Lock()
defer tc.l.Unlock()
if len((*tc).Entries) == 0 {
return 0
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment