-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
I'm making server functionality of Server-Sent-Event on cpp-httplib for my project.
I aware there's example code (ssesvr.cc) in the repository and that's where I began for my own implementation.
In my requirement for the functionality, SSE server should keep client as long as possible even there's nothing to send. For that my implementation dedicate a thread per client and keeps it as long as connected. Problem is server can't aware unexpected disconnection of client without trying to send some data. If that kind of connection is increased, it'll consume entire threadpool after all. I know SSE comment can be used for it. But, I don't want to use it to check connectivity because it makes bunch of useless data to be transferred.
So, I made my own patch to tackle the problem and run existing unittest on Linux. But, it makes failure on ServerTest.ClientStop testcase at following.
Line 1646 in a9cf097
EXPECT_TRUE(sink.is_writable()); |
I think the
EXPECT_TRUE
above should be reconsidered. Because, a sink passed into content provider could be unwritable for some reason if it's based on SocketStream.I modified
detail::SocketStream::is_writable()
in the patch to check socket via is_socket_alive()
. I think, the patch should be applied to SSLSocketStream
as well. I want to contribute the patch with relative unittest and patch if you're OK with changing EXPECT_TRUE
above and behavior of SocketStream
and SSLSocketStream
.