curl_multi_cleanup.md (1828B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_multi_cleanup 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_easy_cleanup (3) 9 - curl_easy_init (3) 10 - curl_multi_get_handles (3) 11 - curl_multi_init (3) 12 Protocol: 13 - All 14 Added-in: 7.9.6 15 --- 16 17 # NAME 18 19 curl_multi_cleanup - close down a multi session 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLMcode curl_multi_cleanup(CURLM *multi_handle); 27 ~~~ 28 29 # DESCRIPTION 30 31 This function is the opposite of curl_multi_init(3). Cleans up and removes a 32 whole multi stack. It does not free or touch any individual easy handles in 33 any way - they still need to be closed individually, using the usual 34 curl_easy_cleanup(3) way. The order of cleaning up should be: 35 36 1 - curl_multi_remove_handle(3) before any easy handles are cleaned up 37 38 2 - curl_easy_cleanup(3) can now be called independently since the easy 39 handle is no longer connected to the multi handle 40 41 3 - curl_multi_cleanup(3) should be called when all easy handles are 42 removed 43 44 When this function is called, remaining entries in the connection pool held by 45 the multi handle are shut down, which might trigger calls to the 46 CURLMOPT_SOCKETFUNCTION(3) callback. 47 48 Passing in a NULL pointer in *multi_handle* makes this function return 49 CURLM_BAD_HANDLE immediately with no other action. 50 51 Any use of the **multi_handle** after this function has been called and have 52 returned, is illegal. 53 # %PROTOCOLS% 54 55 # EXAMPLE 56 57 ~~~c 58 int main(void) 59 { 60 CURLM *multi = curl_multi_init(); 61 62 /* when the multi transfer is done ... */ 63 64 /* remove all easy handles, then: */ 65 curl_multi_cleanup(multi); 66 } 67 ~~~ 68 69 # %AVAILABILITY% 70 71 # RETURN VALUE 72 73 This function returns a CURLMcode indicating success or error. 74 75 CURLM_OK (0) means everything was OK, non-zero means an error occurred, see 76 libcurl-errors(3).