Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ffay committed Nov 28, 2017
1 parent ff18202 commit 76f08a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func (connHandler *ConnHandler) Listen(conn net.Conn, messageHandler interface{}
}

func (connHandler *ConnHandler) Write(msg interface{}) {
buf := connHandler.messageHandler.Encode(msg)
connHandler.WriteTime = time.Now().Unix()
connHandler.conn.Write(buf)
if connHandler.messageHandler != nil {
buf := connHandler.messageHandler.Encode(msg)
connHandler.WriteTime = time.Now().Unix()
connHandler.conn.Write(buf)
}
}
7 changes: 7 additions & 0 deletions src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ func (messageHandler *LPMessageHandler) ConnError(connHandler *ConnHandler) {
if messageHandler.die != nil {
close(messageHandler.die)
}

if connHandler.NextConn != nil {
connHandler.NextConn.NextConn = nil
connHandler.NextConn.conn.Close()
connHandler.NextConn = nil
}

connHandler.messageHandler = nil
messageHandler.connHandler = nil
time.Sleep(time.Second * 3)
Expand Down
2 changes: 2 additions & 0 deletions src/main/realserver_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (messageHandler *RealServerMessageHandler) ConnError(connHandler *ConnHandl
conn.Write(message)
conn.NextConn = nil
}

connHandler.messageHandler = nil
}

func (messageHandler *RealServerMessageHandler) ConnFailed() {
Expand Down

0 comments on commit 76f08a6

Please sign in to comment.