30dayMakeCppServer icon indicating copy to clipboard operation
30dayMakeCppServer copied to clipboard

day16:当echo客户端断开连接时,服务器会发生Segmentation fault

Open Ms-1020 opened this issue 1 year ago • 0 comments

在非阻塞模式下,当某个echo客户端断开连接时,会调用Close函数,进而回调TCPServer中的DeleteConnection函数,导致当前断开连接的客户端的指针被删除。但是在Channel中还会回调Connection中的Business,从而导致空指针异常。

image 此时需要判断当前连接是否已经断开 image

Ms-1020 avatar Dec 25 '23 09:12 Ms-1020