Пример #1
0
func checkTimeout() {
	for k, v := range seqMap {
		waitTime := time.Since(v.t)
		millTime := float64(waitTime.Nanoseconds()) / float64(1000000)
		if millTime >= 200.0 {
			//			fmt.Println(seq, "timeout.")
			haunt.SetRouteResult("7900_xman", v.server, 1, 200)
			delete(seqMap, k)
		}
	}
}
Пример #2
0
func handleReader(conn net.Conn, server string) {
	tmpbuf := make([]byte, 0)
	for {
		buf := make([]byte, 1024)
		reqLen, err := conn.Read(buf)
		if err != nil {
			fmt.Println(err)
			continue
		}
		sMap := make(map[uint32]interface{})
		tmpbuf = UnpackTCPConn(append(tmpbuf, buf[:reqLen]...), &sMap)
		for k, _ := range sMap {
			v, ok := seqMap[k]
			if ok {
				useTime := time.Since(v.t)
				//				fmt.Println(ip, "use time:", useTime, float64(useTime.Nanoseconds())/float64(1000000))
				haunt.SetRouteResult("7900_xman", server, 0, float64(useTime.Nanoseconds())/float64(1000000))
				delete(seqMap, k)
			}
		}
	}
}