22
33#include " launchdarkly/network/curl_multi_manager.hpp"
44
5+ #include < iostream>
56#include < boost/asio/post.hpp>
67
78namespace launchdarkly ::network {
@@ -93,6 +94,8 @@ int CurlMultiManager::socket_callback(CURL* easy,
9394 int what,
9495 void * userp,
9596 void * socketp) {
97+
98+ std::cout << " socket_callback: what: " << what << " socket: " << s << std::endl;
9699 auto * manager = static_cast <CurlMultiManager*>(userp);
97100
98101 std::lock_guard lock (manager->mutex_ );
@@ -101,6 +104,7 @@ int CurlMultiManager::socket_callback(CURL* easy,
101104 manager->reset_read_timeout (easy);
102105
103106 if (what == CURL_POLL_REMOVE) {
107+ std::cout << " socket_callback: remove: " << s << std::endl;
104108 // Remove socket from managed container
105109 if (const auto it = manager->sockets_ .find (s);
106110 it != manager->sockets_ .end ()) {
@@ -257,6 +261,7 @@ void CurlMultiManager::start_socket_monitor(SocketInfo* socket_info,
257261
258262 // Monitor for read events
259263 if (action & CURL_POLL_IN) {
264+ std::cout << " start_socket_monitor: poll in: " << socket_info->sockfd << std::endl;
260265 // Only create new handler if we don't have one or if action changed
261266 if (!socket_info->read_handler || action_changed) {
262267 // Use weak_ptr to safely detect when handle is deleted
@@ -301,10 +306,13 @@ void CurlMultiManager::start_socket_monitor(SocketInfo* socket_info,
301306 };
302307 (*socket_info->read_handler )(); // Initial call
303308 }
309+ } else {
310+ socket_info->read_handler .reset ();
304311 }
305312
306313 // Monitor for write events
307314 if (action & CURL_POLL_OUT) {
315+ std::cout << " start_socket_monitor: poll out: " << socket_info->sockfd << std::endl;
308316 // Only create new handler if we don't have one or if action changed
309317 if (!socket_info->write_handler || action_changed) {
310318 // Use weak_ptr to safely detect when handle is deleted
@@ -349,6 +357,8 @@ void CurlMultiManager::start_socket_monitor(SocketInfo* socket_info,
349357 };
350358 (*socket_info->write_handler )(); // Initial call
351359 }
360+ } else {
361+ socket_info->write_handler .reset ();
352362 }
353363}
354364
0 commit comments