Commit a8f2e95a authored by AlexStocks's avatar AlexStocks

time.Sleep() -> wheel.After()

parent 96c2170a
......@@ -22,6 +22,8 @@
* close net.UDPConn when connected failed
* close net.Conn when connected failed
* Session::EndPointType() -> Session::EndPoint()
* time.Sleep() -> wheel.After()
* do not check server.go:server::caCert
- 2018/03/17
> improvement
......
......@@ -135,7 +135,8 @@ func (c *client) dialTCP() Session {
}
log.Info("net.DialTimeout(addr:%s, timeout:%v) = error{%s}", c.addr, err)
time.Sleep(connInterval)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
}
}
......@@ -163,7 +164,8 @@ func (c *client) dialUDP() Session {
}
if err != nil {
log.Warn("net.DialTimeout(addr:%s, timeout:%v) = error{%s}", c.addr, err)
time.Sleep(connInterval)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
continue
}
......@@ -173,7 +175,8 @@ func (c *client) dialUDP() Session {
if length, err = conn.Write(buf[:len(pingPacket)]); err != nil {
conn.Close()
log.Warn("conn.Write(%s) = {length:%d, err:%s}", pingPacket, length, err)
time.Sleep(connInterval)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
continue
}
conn.SetReadDeadline(wheel.Now().Add(1e9))
......@@ -184,7 +187,8 @@ func (c *client) dialUDP() Session {
if err != nil {
log.Info("conn{%#v}.Read() = {length:%d, err:%s}", conn, length, err)
conn.Close()
time.Sleep(connInterval)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
continue
}
//if err == nil {
......@@ -222,7 +226,8 @@ func (c *client) dialWS() Session {
}
log.Info("websocket.dialer.Dial(addr:%s) = error:%s", c.addr, err)
time.Sleep(connInterval)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
}
}
......@@ -300,7 +305,8 @@ func (c *client) dialWSS() Session {
}
log.Info("websocket.dialer.Dial(addr:%s) = error{%s}", c.addr, err)
time.Sleep(connInterval)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
}
}
......@@ -389,7 +395,8 @@ func (c *client) RunEventLoop(newSession NewSessionCallback) {
if maxTimes < times {
times = maxTimes
}
time.Sleep(time.Duration(int64(times) * connInterval))
// time.Sleep(time.Duration(int64(times) * connInterval))
<-wheel.After(time.Duration(int64(times) * connInterval))
continue
}
times = 0
......
......@@ -89,7 +89,7 @@ func NewWSServer(opts ...ServerOption) Server {
func NewWSSServer(opts ...ServerOption) Server {
s := newServer(WSS_SERVER, opts...)
if s.addr == "" || s.cert == "" || s.privateKey == "" || s.caCert == "" {
if s.addr == "" || s.cert == "" || s.privateKey == "" {
panic(fmt.Sprintf("@addr:%s, @cert:%s, @privateKey:%s, @caCert:%s",
s.addr, s.cert, s.privateKey, s.caCert))
}
......@@ -237,7 +237,8 @@ func (s *server) runTcpEventLoop(newSession NewSessionCallback) {
return
}
if delay != 0 {
time.Sleep(delay)
// time.Sleep(delay)
<-wheel.After(delay)
}
client, err = s.accept(newSession)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment