Update lrstanley/girc dep (#1773)

This commit is contained in:
Wim
2022-03-25 22:01:02 +01:00
committed by GitHub
parent 5d9604cd15
commit 5f75f9886d
11 changed files with 21 additions and 30 deletions

View File

@@ -43,8 +43,7 @@ type ircConn struct {
lastPing time.Time
// lastPong is the last successful time that we pinged the server and
// received a successful pong back.
lastPong time.Time
pingDelay time.Duration
lastPong time.Time
}
// Dialer is an interface implementation of net.Dialer. Use this if you would
@@ -477,7 +476,7 @@ func (c *Client) write(event *Event) {
func (c *ircConn) rate(chars int) time.Duration {
_time := time.Second + ((time.Duration(chars) * time.Second) / 100)
if c.writeDelay += _time - time.Now().Sub(c.lastWrite); c.writeDelay < 0 {
if c.writeDelay += _time - time.Since(c.lastWrite); c.writeDelay < 0 {
c.writeDelay = 0
}
@@ -607,15 +606,16 @@ func (c *Client) pingLoop(ctx context.Context, errs chan error, wg *sync.WaitGro
if time.Since(c.conn.lastPong) > c.Config.PingDelay+(60*time.Second) {
// It's 60 seconds over what out ping delay is, connection
// has probably dropped.
errs <- ErrTimedOut{
err := ErrTimedOut{
TimeSinceSuccess: time.Since(c.conn.lastPong),
LastPong: c.conn.lastPong,
LastPing: c.conn.lastPing,
Delay: c.Config.PingDelay,
}
wg.Done()
c.conn.mu.RUnlock()
errs <- err
wg.Done()
return
}
c.conn.mu.RUnlock()