You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
every operation of *Session.Cmsg in session.go is like this
this.mu.Lock() defer this.mu.Unlock() blabla~~~
but in service.go line 237-241
// Publish will message if WillFlag is set. Server side only. if !this.client && this.sess.Cmsg.WillFlag() { glog.Infof("(%s) service/stop: connection unexpectedly closed. Sending Will.", this.cid()) this.onPublish(this.sess.Will) }
there is no lock when operating this.sess.Cmsg
My opinion is:
make Session.Cmsg private
adding the lines below to session.go, and using the functions instead of this.sess.Cmsg
if possible, change this.mu from sync.Mutex to sync.RWMutex
every operation of
*Session.Cmsg
in session.go is like thisthis.mu.Lock()
defer this.mu.Unlock()
blabla~~~
but in service.go line 237-241
// Publish will message if WillFlag is set. Server side only.
if !this.client && this.sess.Cmsg.WillFlag() {
glog.Infof("(%s) service/stop: connection unexpectedly closed. Sending Will.", this.cid())
this.onPublish(this.sess.Will)
}
there is no lock when operating
this.sess.Cmsg
My opinion is:
Session.Cmsg
privatethis.sess.Cmsg
sync.Mutex
tosync.RWMutex
func (this *Session) WillFlag() bool {
this.mu.Lock()
defer this.mu.Unlock()
return this.cmsg.WillFlag()
}
func (this *Session) SetWillFlag(v bool) {
this.mu.Lock()
defer this.mu.Unlock()
this.cmsg.SetWillFlag(v)
}
func (this *Session) CleanSession() bool {
this.mu.Lock()
defer this.mu.Unlock()
return this.cmsg.CleanSession()
}
Another place of this problem in memtopics.go line 128-130
func (this *memTopics) Close() error {
this.sroot = nil
this.rroot = nil
return nil
}
shoud change to
func (this *memTopics) Close() error {
this.smu.Lock()
this.sroot = nil
this.smu.Unlock()
this.rmu.Lock()
this.rroot = nil
this.rmu.Unlock()
}
I'll Pull Request later when I complete my coding
The text was updated successfully, but these errors were encountered: