diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index c32250e1..1f69d655 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -19,7 +19,7 @@ type dbEvent struct { type userGroup struct { groupId int64 - userHash sync.Map + userHash *sync.Map } type mailMgr struct { @@ -89,7 +89,7 @@ func (this *mailMgr) loadGroups() { if this.getGroup(groupId) != nil { panic(fmt.Sprintf("mailMgr.loadGroups group_id error")) } - p := new(userGroup) + p := newUserGroup() p.groupId = groupId this.addGroup(p) }, @@ -456,7 +456,18 @@ func (this* mailMgr) procGroupUpdate(e *dbEvent) { if err != nil { return } + groupId := q5.ToInt64(ds.GetByName("group_id")) + g := this.getGroup(groupId) + if g == nil { + p := newUserGroup() + p.groupId = groupId + this.addGroup(g) + } else { + g.userHash = new(sync.Map) + } if ds.Next() { + memberId := ds.GetByName("member_id") + g.userHash.Store(memberId, q5.ToInt64(ds.GetByName("idx"))) return } else { panic(fmt.Sprintf("procGroupUpdate1 error:%s", err)); @@ -489,3 +500,9 @@ func (this* mailMgr) procGroupUpdate(e *dbEvent) { } }) } + +func newUserGroup() *userGroup { + g := new(userGroup) + g.userHash = new(sync.Map) + return g +}