diff --git a/server/imserver/app.go b/server/imserver/app.go index e8619995..8d30d5b0 100644 --- a/server/imserver/app.go +++ b/server/imserver/app.go @@ -3,7 +3,6 @@ package main import ( "time" "fmt" - "sync" "q5" "f5" @@ -12,19 +11,17 @@ import ( ) type App struct { - msgMutex sync.Mutex - msgList q5.ListHead - workList q5.ListHead + netMsgQueue q5.Queue } var app = new (App) +func (this *App) GetPkgName() string { + return "imserver" +} + func (this *App) Init() { - //f5.App = &this.F5App - //f5.App.SetPkgName("imserver") - //this.F5App.Init(this.Update) - this.msgList.Init(nil) - this.workList.Init(nil) + this.netMsgQueue.Init() f5.LoadMetaTable(mt.Table) fmt.Println("listen_port", mt.Table.IMServer.GetById(0).GetListenPort()) @@ -36,19 +33,12 @@ func (this *App) Init() { func (this *App) UnInit() { handlerMgr.UnInit() wspListener.UnInit() - //this.F5App.UnInit() } func (this *App) Update() { - if this.workList.Empty() { - this.msgMutex.Lock() - defer this.msgMutex.Unlock() - if !this.msgList.Empty() { - this.msgList.ReplaceInit(&this.workList) - } - } - for !this.workList.Empty() { - next := this.workList.Next() + this.netMsgQueue.Fetch() + for !this.netMsgQueue.WorkList.Empty() { + next := this.netMsgQueue.WorkList.Next() hdr, ok := next.GetData().(*f5.MsgHdr) if ok { handler := cs.GetNetMsgHandler(hdr.MsgId) @@ -83,14 +73,6 @@ func (this *App) goReportServerState() { } func (this *App) addNetMsg(hdr *f5.MsgHdr) { - { - this.msgMutex.Lock() - defer this.msgMutex.Unlock() - this.msgList.AddTail(&hdr.Entry); - } - //this.NotifyLoopCond() -} - -func (this *App) GetPkgName() string { - return "imserver" + this.netMsgQueue.Push(&hdr.Entry) + f5.GetApp().NotifyLoopCond() } diff --git a/server/imserver/mt/export.go b/server/imserver/mt/export.go index cf040ee8..3455ab25 100644 --- a/server/imserver/mt/export.go +++ b/server/imserver/mt/export.go @@ -10,7 +10,7 @@ type table struct { var Table = f5.New(func (this* table) { this.IMServer = f5.New(func (this *IMServerTable) { - this.FileName = "imserver.cluster.json" + this.FileName = "../config/imserver.cluster.json" this.PrimKey = "" }); }) diff --git a/third_party/q5 b/third_party/q5 index 7bffd9a6..aecf26a4 160000 --- a/third_party/q5 +++ b/third_party/q5 @@ -1 +1 @@ -Subproject commit 7bffd9a638a1888f22f68a8b191bc9e4b54e3e99 +Subproject commit aecf26a45c74547bb724f59653331dcc34f16974