1ARES_LIBRARY_CLEANUP(3) Library Functions Manual ARES_LIBRARY_CLEANUP(3)
2
3
4
6 ares_library_cleanup - c-ares library deinitialization
7
9 #include <ares.h>
10
11 void ares_library_cleanup(void)
12
14 The ares_library_cleanup function uninitializes the c-ares library,
15 freeing all resources previously acquired by ares_library_init(3) when
16 the library was initialized, provided there was only one single previ‐
17 ous call to ares_library_init(3). If there was more than one previous
18 call to ares_library_init(3), this function uninitializes the c-ares
19 library only if it is the call matching the call to ares_li‐
20 brary_init(3) which initialized the library (usually the very first
21 call to ares_library_init(3)). Other calls to ares_library_cleanup(3)
22 have no effect other than decrementing an internal counter.
23
24 This function must be called when the program using c-ares will no
25 longer need any c-ares function. Once the program has called ares_li‐
26 brary_cleanup(3) sufficiently often such that the library is unini‐
27 tialised, it shall not make any further call to any c-ares function.
28
29 This function does not cancel any pending c-ares lookups or requests
30 previously done. Program must use ares_cancel(3) for this purpose.
31
32 This function is not thread safe. You have to call it once the program
33 is about to terminate, but this call must be done once the program has
34 terminated every single thread that it could have initiated. This is
35 required to avoid potential race conditions in library deinitializa‐
36 tion, and also due to the fact that ares_library_cleanup(3) might call
37 functions from other libraries that are thread unsafe, and could con‐
38 flict with any other thread that is already using these other li‐
39 braries.
40
41 Win32/64 application DLLs shall not call ares_library_cleanup(3) from
42 the DllMain function. Doing so will produce deadlocks and other prob‐
43 lems.
44
46 This function was first introduced in c-ares version 1.7.0 along with
47 the definition of preprocessor symbol CARES_HAVE_ARES_LIBRARY_CLEANUP
48 as an indication of the availability of this function. Reference count‐
49 ing in ares_library_init(3) and ares_library_cleanup(3), which requires
50 calls to the former function to match calls to the latter, is present
51 since c-ares version 1.10.0. Earlier versions would deinitialize the
52 library on the first call to ares_library_cleanup(3).
53
54 Since the introduction of this function, it is absolutely mandatory to
55 call it for any Win32/64 program using c-ares.
56
57 Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
58 ares_library_cleanup(3) due to the fact that currently it is nearly a
59 do-nothing function on non-Win32/64 platforms.
60
62 ares_library_init(3), ares_cancel(3)
63
65 Yang Tse
66
67 Copyright 1998 by the Massachusetts Institute of Technology.
68 Copyright (C) 2004-2009 by Daniel Stenberg.
69
70
71
72 19 May 2009 ARES_LIBRARY_CLEANUP(3)