Skip to content

Commit 8ee6a0d

Browse files
committed
Remove handlers that CURL no longer needs.
1 parent 93c498a commit 8ee6a0d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

examples/hello-cpp-client/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Set INIT_TIMEOUT_MILLISECONDS to the amount of time you will wait for
1414
// the client to become initialized.
15-
#define INIT_TIMEOUT_MILLISECONDS 3000
15+
#define INIT_TIMEOUT_MILLISECONDS 9999999999
1616

1717
char const* get_with_env_fallback(char const* source_val,
1818
char const* env_variable,

libs/networking/src/curl_multi_manager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "launchdarkly/network/curl_multi_manager.hpp"
44

5+
#include <iostream>
56
#include <boost/asio/post.hpp>
67

78
namespace 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

Comments
 (0)