|
26 | 26 | #include <stdio.h> |
27 | 27 | #include <stdlib.h> |
28 | 28 | #include <curl/curl.h> |
| 29 | +#include <curl/multi.h> |
29 | 30 |
|
30 | 31 | #include "../../mem/shm_mem.h" |
31 | 32 | #include "../../async.h" |
@@ -1569,10 +1570,11 @@ int connect_only(preconnect_urls *precon_urls, int total_cons) { |
1569 | 1570 | CURLM *multi_handle; |
1570 | 1571 | OSS_CURLM *multi_list; |
1571 | 1572 | CURL **list; |
| 1573 | + struct CURLMsg *m; |
1572 | 1574 | preconnect_urls *start, *next; |
1573 | 1575 | char *url; |
1574 | 1576 | long busy_wait, timer; |
1575 | | - int num_of_connections, exit_code = 0; |
| 1577 | + int msgq, num_of_connections, exit_code = 0; |
1576 | 1578 |
|
1577 | 1579 | curl_share = get_curl_share(); |
1578 | 1580 |
|
@@ -1645,19 +1647,18 @@ int connect_only(preconnect_urls *precon_urls, int total_cons) { |
1645 | 1647 | usleep(1000UL * busy_wait); |
1646 | 1648 | LM_DBG("Creating warm pool connection, running handles %d\n", running_handles); |
1647 | 1649 | } while (running_handles != 0); |
| 1650 | + |
1648 | 1651 | 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); |
1655 | 1656 | if (mrc != CURLM_OK) { |
1656 | 1657 | LM_ERR("curl_multi_remove_handle: %s\n", curl_multi_strerror(mrc)); |
1657 | 1658 | } |
1658 | | - curl_easy_cleanup(list[i]); |
| 1659 | + curl_easy_cleanup(m->easy_handle); |
1659 | 1660 | } |
1660 | | - } |
| 1661 | + } while (m); |
1661 | 1662 |
|
1662 | 1663 | start = precon_urls; |
1663 | 1664 |
|
|
0 commit comments