diff options
author | Corey Hulen <corey@hulen.com> | 2015-08-21 09:00:23 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-08-21 09:00:23 -0700 |
commit | 1ba694626128870698a6e011047ed899f5f90ba4 (patch) | |
tree | c49dd9fd25517457215f2e893b65a8760daba3a7 | |
parent | ddcdcc3e2c85efbfd1d91d69c0f5c0af7c7cb1c7 (diff) | |
parent | e4b66c3ff41bcac47f026151a7cb1b19b1217672 (diff) | |
download | chat-1ba694626128870698a6e011047ed899f5f90ba4.tar.gz chat-1ba694626128870698a6e011047ed899f5f90ba4.tar.bz2 chat-1ba694626128870698a6e011047ed899f5f90ba4.zip |
Merge pull request #430 from mattermost/fixing-build
Fixing race condition
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | api/context.go | 8 | ||||
-rw-r--r-- | model/client.go | 2 | ||||
-rw-r--r-- | store/sql_channel_store.go | 5 | ||||
-rw-r--r-- | store/store.go | 4 |
5 files changed, 20 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore index 97de7eea5..79761adac 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ web/sass-files/sass/.sass-cache/ # Default local file storage data/* api/data/* + +.agignore +.ctags +tags diff --git a/api/context.go b/api/context.go index e3f279e90..8babf85f2 100644 --- a/api/context.go +++ b/api/context.go @@ -196,7 +196,9 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (c *Context) LogAudit(extraInfo string) { audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - Srv.Store.Audit().Save(audit) + if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { + c.LogError(r.Err) + } } func (c *Context) LogAuditWithUserId(userId, extraInfo string) { @@ -206,7 +208,9 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) { } audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - Srv.Store.Audit().Save(audit) + if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { + c.LogError(r.Err) + } } func (c *Context) LogError(err *model.AppError) { diff --git a/model/client.go b/model/client.go index 6fcfa5043..17e2466df 100644 --- a/model/client.go +++ b/model/client.go @@ -5,6 +5,7 @@ package model import ( "bytes" + l4g "code.google.com/p/log4go" "fmt" "io/ioutil" "net/http" @@ -93,6 +94,7 @@ func getCookie(name string, resp *http.Response) *http.Cookie { func (c *Client) Must(result *Result, err *AppError) *Result { if err != nil { + l4g.Close() time.Sleep(time.Second) panic(err) } diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index cf34f2847..a7577e645 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -4,6 +4,7 @@ package store import ( + "fmt" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" ) @@ -153,8 +154,10 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel { channel.ExtraUpdated() - if count, err := s.GetMaster().Update(channel); err != nil || count != 1 { + if count, err := s.GetMaster().Update(channel); err != nil { result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", "id="+channel.Id+", "+err.Error()) + } else if count != 1 { + result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", fmt.Sprintf("id=%v, count=%v", channel.Id, count)) } storeChannel <- result diff --git a/store/store.go b/store/store.go index 617ea7f2b..8dbf12b55 100644 --- a/store/store.go +++ b/store/store.go @@ -4,7 +4,9 @@ package store import ( + l4g "code.google.com/p/log4go" "github.com/mattermost/platform/model" + "time" ) type StoreResult struct { @@ -17,6 +19,8 @@ type StoreChannel chan StoreResult func Must(sc StoreChannel) interface{} { r := <-sc if r.Err != nil { + l4g.Close() + time.Sleep(time.Second) panic(r.Err) } |