2008年2月27日 星期三

研發筆記-如何避免client端不正常斷線,導致segmentation fault.

事件:
在設計UPNP media server的時候,同時間有很多client來request,因此不正常斷線的情形必定發生。


原因:
For avoiding the clients send TCP RESET flag, (the same request in a short period) to close the connection, and make our daemon write into a broken connection, then the SIGPIPE will cause an unexpected exit.

解法:在main()註冊一個 signal(SIGPIPE, SIG_IGN);

0 意見: