Pooler data race fix and experimental qt5 interface.
Fixed Pooler's data race which occurs on every server's pinging goroutine creation, because of uncontrolled write to current requests counter. Protected it with mutex. Added very experimental and not-yet-working qt5 interface. Maybe it will be completed someday.
This commit is contained in:
@@ -29,6 +29,8 @@ type Pooler struct {
|
||||
maxrequests int
|
||||
// Packet prefix.
|
||||
pp string
|
||||
// Current requests counter mutex.
|
||||
cur_requests_mutex sync.Mutex
|
||||
}
|
||||
|
||||
func (p *Pooler) Initialize() {
|
||||
@@ -73,11 +75,15 @@ func (p *Pooler) PingServers(servers_type string) {
|
||||
}
|
||||
}
|
||||
wait.Add(1)
|
||||
p.cur_requests_mutex.Lock()
|
||||
cur_requests += 1
|
||||
p.cur_requests_mutex.Unlock()
|
||||
go func(srv *datamodels.Server) {
|
||||
defer wait.Done()
|
||||
p.pingServersExecutor(srv)
|
||||
p.cur_requests_mutex.Lock()
|
||||
cur_requests -= 1
|
||||
p.cur_requests_mutex.Unlock()
|
||||
}(server_to_ping.Server)
|
||||
}
|
||||
wait.Wait()
|
||||
|
Reference in New Issue
Block a user