Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ffay committed Nov 23, 2017
1 parent c5346c5 commit ff18202
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (connHandler *ConnHandler) Listen(conn net.Conn, messageHandler interface{}
connHandler.conn = conn
connHandler.messageHandler = messageHandler.(MessageHandler)
connHandler.Active = true
connHandler.ReadTime = time.Now().Unix()
connHandler.WriteTime = connHandler.ReadTime
connHandler.messageHandler.ConnSuccess(connHandler)
for {
buf := make([]byte, 1024*8)
Expand Down
4 changes: 3 additions & 1 deletion src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ func (messageHandler *LPMessageHandler) ConnError(connHandler *ConnHandler) {
if messageHandler.die != nil {
close(messageHandler.die)
}
connHandler.messageHandler = nil
messageHandler.connHandler = nil
time.Sleep(time.Second * 3)
}

Expand All @@ -274,7 +276,7 @@ func (messageHandler *LPMessageHandler) startHeartbeat() {
select {
case <-time.After(time.Second * HEARTBEAT_INTERVAL):
if time.Now().Unix()-messageHandler.connHandler.ReadTime >= 2*HEARTBEAT_INTERVAL {
log.Println("proxy connection timeout:", messageHandler.connHandler)
log.Println("proxy connection timeout:", messageHandler.connHandler, time.Now().Unix()-messageHandler.connHandler.ReadTime)
messageHandler.connHandler.conn.Close()
return
}
Expand Down

0 comments on commit ff18202

Please sign in to comment.