Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (this *service) processIncoming(msg message.Message) error {

case *message.DisconnectMessage:
// For DISCONNECT message, we should quit
this.sess.Cmsg.SetWillFlag(false)
this.sess.SetWillFlag(false)
return errDisconnect

default:
Expand Down
4 changes: 2 additions & 2 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (this *service) stop() {
}

// Publish will message if WillFlag is set. Server side only.
if !this.client && this.sess.Cmsg.WillFlag() {
if !this.client && this.sess.WillFlag() {
glog.Infof("(%s) service/stop: connection unexpectedly closed. Sending Will.", this.cid())
this.onPublish(this.sess.Will)
}
Expand All @@ -246,7 +246,7 @@ func (this *service) stop() {
}

// Remove the session from session store if it's suppose to be clean session
if this.sess.Cmsg.CleanSession() && this.sessMgr != nil {
if this.sess.CleanSession() && this.sessMgr != nil {
this.sessMgr.Del(this.sess.ID())
}

Expand Down
19 changes: 18 additions & 1 deletion sessions/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Session struct {
Pingack *Ackqueue

// cmsg is the CONNECT message
Cmsg *message.ConnectMessage
cmsg *message.ConnectMessage

// Will message to publish if connect is closed unexpectedly
Will *message.PublishMessage
Expand Down Expand Up @@ -201,3 +201,20 @@ func (this *Session) Topics() ([]string, []byte, error) {
func (this *Session) ID() string {
return string(this.Cmsg.ClientId())
}
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()
}
4 changes: 4 additions & 0 deletions topics/memtopics.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ func (this *memTopics) Retained(topic []byte, msgs *[]*message.PublishMessage) e
}

func (this *memTopics) Close() error {
this.smu.Lock()
this.sroot = nil
this.smu.Unlock()
this.rmu.Lock()
this.rroot = nil
this.rmu.Unlock()
return nil
}

Expand Down