blob: d60c378982a19744ffe24cd8ff72b9d940f44fb2 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001.\"
2.\" Copyright 1998 by the Massachusetts Institute of Technology.
3.\" Copyright (C) 2004-2009 by Daniel Stenberg
4.\"
5.\" Permission to use, copy, modify, and distribute this
6.\" software and its documentation for any purpose and without
7.\" fee is hereby granted, provided that the above copyright
8.\" notice appear in all copies and that both that copyright
9.\" notice and this permission notice appear in supporting
10.\" documentation, and that the name of M.I.T. not be used in
11.\" advertising or publicity pertaining to distribution of the
12.\" software without specific, written prior permission.
13.\" M.I.T. makes no representations about the suitability of
14.\" this software for any purpose. It is provided "as is"
15.\" without express or implied warranty.
16.\"
17.TH ARES_LIBRARY_CLEANUP 3 "19 May 2009"
18.SH NAME
19ares_library_cleanup \- c-ares library deinitialization
20.SH SYNOPSIS
21.nf
22.B #include <ares.h>
23.PP
24.B void ares_library_cleanup(void)
25.PP
26.B cc file.c -lcares
27.fi
28.SH DESCRIPTION
29.PP
30The
31.B ares_library_cleanup
32function uninitializes the c-ares library, freeing all resources
33previously acquired by \fIares_library_init(3)\fP when the library
34was initialized, provided there was only one single previous call to
35\fIares_library_init(3)\fP. If there was more than one previous call to
36\fIares_library_init(3)\fP, this function uninitializes the c-ares
37library only if it is the call matching the call to
38\fIares_library_init(3)\fP which initialized the library
39(usually the very first call to \fIares_library_init(3)\fP).
40Other calls to \fIares_library_cleanup(3)\fP have no effect other than
41decrementing an internal counter.
42.PP
43This function must be called when the program using c-ares will
44no longer need any c-ares function. Once the program has called
45\fIares_library_cleanup(3)\fP sufficiently often such that the
46library is uninitialised, it shall not make any further call to any
47c-ares function.
48.PP
49This function does not cancel any pending c-ares lookups or requests
50previously done. Program must use \fIares_cancel(3)\fP for this purpose.
51.PP
52.B This function is not thread safe.
53You have to call it once the program is about to terminate, but this call must
54be done once the program has terminated every single thread that it could have
55initiated. This is required to avoid potential race conditions in library
56deinitialization, and also due to the fact that \fIares_library_cleanup(3)\fP
57might call functions from other libraries that are thread unsafe, and could
58conflict with any other thread that is already using these other libraries.
59.PP
60Win32/64 application DLLs shall not call \fIares_library_cleanup(3)\fP from
61the DllMain function. Doing so will produce deadlocks and other problems.
62.SH AVAILABILITY
63This function was first introduced in c-ares version 1.7.0 along with the
64definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an
65indication of the availability of this function. Reference counting in
66\fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires
67calls to the former function to match calls to the latter, is present since
68c-ares version 1.10.0.
69Earlier versions would deinitialize the library on the first call
70to \fIares_library_cleanup()\fP.
71.PP
72Since the introduction of this function, it is absolutely mandatory to call it
73for any Win32/64 program using c-ares.
74.PP
75Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
76\fIares_library_cleanup(3)\fP due to the fact that \fIcurrently\fP it is nearly
77a do-nothing function on non-Win32/64 platforms.
78.SH SEE ALSO
79.BR ares_library_init(3),
80.BR ares_cancel(3)
81.SH AUTHOR
82Yang Tse
83.PP
84Copyright 1998 by the Massachusetts Institute of Technology.
85.br
86Copyright (C) 2004-2009 by Daniel Stenberg.