mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fixing race conditions in the code base (#5966)
* Adding initial race detector * Remove setting of config twice * Fixing config file watch and config reload on license save * Fixing config file watch and config reload on license save * Fixing build error * Fixing locking issue * Fixing makefile * Fixing race in config * Fixing race in status unit test * Adding EE race tests * Fixing race in cluster info * Removing code that's isn't needed * Fixing some more races * Fixing govet issue
This commit is contained in:
committed by
Harrison Healey
parent
32460bf63b
commit
6bf080393d
@@ -61,7 +61,6 @@ func TestSendChangeUsernameEmail(t *testing.T) {
|
||||
|
||||
func TestSendEmailChangeVerifyEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var userId string = "5349853498543jdfvndf9834"
|
||||
var newUserEmail string = "newtest@example.com"
|
||||
@@ -113,7 +112,6 @@ func TestSendEmailChangeVerifyEmail(t *testing.T) {
|
||||
|
||||
func TestSendEmailChangeEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var oldEmail string = "test@example.com"
|
||||
var newUserEmail string = "newtest@example.com"
|
||||
@@ -161,7 +159,6 @@ func TestSendEmailChangeEmail(t *testing.T) {
|
||||
|
||||
func TestSendVerifyEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var userId string = "5349853498543jdfvndf9834"
|
||||
var userEmail string = "test@example.com"
|
||||
@@ -213,7 +210,6 @@ func TestSendVerifyEmail(t *testing.T) {
|
||||
|
||||
func TestSendSignInChangeEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var email string = "test@example.com"
|
||||
var locale string = "en"
|
||||
@@ -261,7 +257,6 @@ func TestSendSignInChangeEmail(t *testing.T) {
|
||||
|
||||
func TestSendWelcomeEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var userId string = "32432nkjnijn432uj32"
|
||||
var email string = "test@example.com"
|
||||
@@ -355,7 +350,6 @@ func TestSendWelcomeEmail(t *testing.T) {
|
||||
|
||||
func TestSendPasswordChangeEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var email string = "test@example.com"
|
||||
var locale string = "en"
|
||||
@@ -403,7 +397,6 @@ func TestSendPasswordChangeEmail(t *testing.T) {
|
||||
|
||||
func TestSendMfaChangeEmail(t *testing.T) {
|
||||
Setup()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var email string = "test@example.com"
|
||||
var locale string = "en"
|
||||
@@ -488,7 +481,6 @@ func TestSendMfaChangeEmail(t *testing.T) {
|
||||
|
||||
func TestSendInviteEmails(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var email1 string = "test1@example.com"
|
||||
var email2 string = "test2@example.com"
|
||||
@@ -564,7 +556,6 @@ func TestSendInviteEmails(t *testing.T) {
|
||||
|
||||
func TestSendPasswordReset(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
utils.LoadConfig("config.json")
|
||||
|
||||
var siteURL string = "http://test.mattermost.io"
|
||||
// var locale string = "en"
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"hash/fnv"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"sync/atomic"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
|
||||
type Hub struct {
|
||||
connections []*WebConn
|
||||
count int64
|
||||
register chan *WebConn
|
||||
unregister chan *WebConn
|
||||
broadcast chan *model.WebSocketEvent
|
||||
@@ -43,12 +45,12 @@ func NewWebHub() *Hub {
|
||||
func TotalWebsocketConnections() int {
|
||||
// This is racy, but it's only used for reporting information
|
||||
// so it's probably OK
|
||||
count := 0
|
||||
count := int64(0)
|
||||
for _, hub := range hubs {
|
||||
count = count + len(hub.connections)
|
||||
count = count + atomic.LoadInt64(&hub.count)
|
||||
}
|
||||
|
||||
return count
|
||||
return int(count)
|
||||
}
|
||||
|
||||
func HubStart() {
|
||||
@@ -248,6 +250,7 @@ func (h *Hub) Start() {
|
||||
select {
|
||||
case webCon := <-h.register:
|
||||
h.connections = append(h.connections, webCon)
|
||||
atomic.StoreInt64(&h.count, int64(len(h.connections)))
|
||||
|
||||
case webCon := <-h.unregister:
|
||||
userId := webCon.UserId
|
||||
|
||||
Reference in New Issue
Block a user