File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ func (nc *netConn)Redial() {
7272 nc .conn .Store (conn )
7373 }
7474 if err != nil {
75- time .Sleep (100 * time . Millisecond )
75+ time .Sleep (RetryTimeout )
7676 }
7777 }
7878}
@@ -114,7 +114,7 @@ func (nc *netConn)nc() net.Conn {
114114 return conn
115115 }
116116 }
117- time .Sleep (time . Millisecond )
117+ time .Sleep (RetryTimeout )
118118 }
119119 return & nullConn { nc .network , nc .address }
120120}
Original file line number Diff line number Diff line change @@ -14,8 +14,11 @@ type (
1414 Server Conn
1515 Pkt Packet
1616 }
17+ )
1718
18-
19+ var (
20+ IOTimeout time.Duration = 2 * time .Second
21+ RetryTimeout time.Duration = 50 * time .Millisecond
1922)
2023
2124
@@ -145,7 +148,7 @@ func (p *pool)rloop(server Conn, pktchan chan Packet) {
145148 return
146149
147150 default :
148- server .SetReadDeadline (time .Now ().Add (100 * time . Millisecond ))
151+ server .SetReadDeadline (time .Now ().Add (IOTimeout ))
149152 pkt ,err = pf .Packet ()
150153
151154 switch {
@@ -158,7 +161,7 @@ func (p *pool)rloop(server Conn, pktchan chan Packet) {
158161 p .reconnect (server , pktchan )
159162
160163 default :
161- time .Sleep (5 * time . Second )
164+ time .Sleep (IOTimeout )
162165// log.Println(err)
163166 }
164167 }
@@ -177,13 +180,13 @@ func (p *pool)wloop(server Conn, send_to chan Packet) {
177180 return
178181
179182 case data := <- send_to :
180- server .SetWriteDeadline (time .Now ().Add (100 * time . Millisecond ))
183+ server .SetWriteDeadline (time .Now ().Add (IOTimeout ))
181184 _ , err = data .WriteTo (server )
182185
183186 for err != nil {
184187// log.Println(err)
185188 p .reconnect (server , send_to )
186- server .SetWriteDeadline (time .Now ().Add (100 * time . Millisecond ))
189+ server .SetWriteDeadline (time .Now ().Add (IOTimeout ))
187190 _ ,err = data .WriteTo (server )
188191 }
189192 }
You can’t perform that action at this time.
0 commit comments