1
This commit is contained in:
@@ -16,8 +16,6 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var pool = NewSimplePoll(100)
|
||||
|
||||
//入口
|
||||
func ListenTcp() {
|
||||
l, err := net.Listen("tcp", ":8000")
|
||||
@@ -33,7 +31,7 @@ func ListenTcp() {
|
||||
break
|
||||
}
|
||||
|
||||
printFunc := func() {
|
||||
go func() {
|
||||
defer func() {
|
||||
// 捕获异常 防止waitGroup阻塞
|
||||
if err := recover(); err != nil {
|
||||
@@ -47,24 +45,7 @@ func ListenTcp() {
|
||||
t = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
pool.Add(printFunc)
|
||||
pool.Run()
|
||||
//go func() {
|
||||
// defer func() {
|
||||
// // 捕获异常 防止waitGroup阻塞
|
||||
// if err := recover(); err != nil {
|
||||
// fmt.Println("recover err = ", err)
|
||||
// return
|
||||
// }
|
||||
// }()
|
||||
//
|
||||
// t := NewTcpClient()
|
||||
// if err := handleConn(c, t); err != nil {
|
||||
// t = nil
|
||||
// return
|
||||
// }
|
||||
//}()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +185,7 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
|
||||
return
|
||||
}
|
||||
|
||||
workFunc := func() {
|
||||
go func() {
|
||||
for {
|
||||
if t.TimeoutMap[printNo] == true {
|
||||
timeNow := time.Now()
|
||||
@@ -225,31 +206,7 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
pool.Add(workFunc)
|
||||
pool.Run()
|
||||
//go func() {
|
||||
// for {
|
||||
// if t.TimeoutMap[printNo] == true {
|
||||
// timeNow := time.Now()
|
||||
// timeStart := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
|
||||
// timeEnd := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
|
||||
// prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait}, timeStart.AddDate(0, 0, -1), timeEnd, offset, pageSize)
|
||||
// for _, printMsg := range prints {
|
||||
// printMsg.Status = printMsgAlreadyLoad
|
||||
// //先避免重复读再插到channel?
|
||||
// if _, err := dao.UpdateEntity(db, printMsg, "Status"); err == nil {
|
||||
// if err = t.addMsgChan(printMsg); err != nil {
|
||||
// globals.SugarLogger.Debugf("HandleTcpMessages addMsgChan Err: %v", err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
//}()
|
||||
}()
|
||||
}
|
||||
|
||||
func (t *TcpClient) readTimeoutMap(key string) bool {
|
||||
|
||||
Reference in New Issue
Block a user