Skip to content

Commit c72c51f

Browse files
Change curl multi get handles, not available on all versions
1 parent 3af53f0 commit c72c51f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

modules/rest_client/rest_methods.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdio.h>
2727
#include <stdlib.h>
2828
#include <curl/curl.h>
29+
#include <curl/multi.h>
2930

3031
#include "../../mem/shm_mem.h"
3132
#include "../../async.h"
@@ -1569,10 +1570,11 @@ int connect_only(preconnect_urls *precon_urls, int total_cons) {
15691570
CURLM *multi_handle;
15701571
OSS_CURLM *multi_list;
15711572
CURL **list;
1573+
struct CURLMsg *m;
15721574
preconnect_urls *start, *next;
15731575
char *url;
15741576
long busy_wait, timer;
1575-
int num_of_connections, exit_code = 0;
1577+
int msgq, num_of_connections, exit_code = 0;
15761578

15771579
curl_share = get_curl_share();
15781580

@@ -1645,19 +1647,18 @@ int connect_only(preconnect_urls *precon_urls, int total_cons) {
16451647
usleep(1000UL * busy_wait);
16461648
LM_DBG("Creating warm pool connection, running handles %d\n", running_handles);
16471649
} while (running_handles != 0);
1650+
16481651
cleanup:
1649-
list = (CURL **) curl_multi_get_handles(multi_handle);
1650-
1651-
if (list) {
1652-
for (int i = 0; list[i]; i++) {
1653-
get_easy_status(list[i], multi_handle, &rc);
1654-
mrc = curl_multi_remove_handle(multi_handle, list[i]);
1652+
do {
1653+
m = curl_multi_info_read(multi_handle, &msgq);
1654+
if (m && m->msg == CURLMSG_DONE) {
1655+
mrc = curl_multi_remove_handle(multi_handle, m->easy_handle);
16551656
if (mrc != CURLM_OK) {
16561657
LM_ERR("curl_multi_remove_handle: %s\n", curl_multi_strerror(mrc));
16571658
}
1658-
curl_easy_cleanup(list[i]);
1659+
curl_easy_cleanup(m->easy_handle);
16591660
}
1660-
}
1661+
} while (m);
16611662

16621663
start = precon_urls;
16631664

0 commit comments

Comments
 (0)