lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | .\" |
| 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 |
| 19 | ares_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 |
| 30 | The |
| 31 | .B ares_library_cleanup |
| 32 | function uninitializes the c-ares library, freeing all resources |
| 33 | previously acquired by \fIares_library_init(3)\fP when the library |
| 34 | was 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 |
| 37 | library 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). |
| 40 | Other calls to \fIares_library_cleanup(3)\fP have no effect other than |
| 41 | decrementing an internal counter. |
| 42 | .PP |
| 43 | This function must be called when the program using c-ares will |
| 44 | no longer need any c-ares function. Once the program has called |
| 45 | \fIares_library_cleanup(3)\fP sufficiently often such that the |
| 46 | library is uninitialised, it shall not make any further call to any |
| 47 | c-ares function. |
| 48 | .PP |
| 49 | This function does not cancel any pending c-ares lookups or requests |
| 50 | previously done. Program must use \fIares_cancel(3)\fP for this purpose. |
| 51 | .PP |
| 52 | .B This function is not thread safe. |
| 53 | You have to call it once the program is about to terminate, but this call must |
| 54 | be done once the program has terminated every single thread that it could have |
| 55 | initiated. This is required to avoid potential race conditions in library |
| 56 | deinitialization, and also due to the fact that \fIares_library_cleanup(3)\fP |
| 57 | might call functions from other libraries that are thread unsafe, and could |
| 58 | conflict with any other thread that is already using these other libraries. |
| 59 | .PP |
| 60 | Win32/64 application DLLs shall not call \fIares_library_cleanup(3)\fP from |
| 61 | the DllMain function. Doing so will produce deadlocks and other problems. |
| 62 | .SH AVAILABILITY |
| 63 | This function was first introduced in c-ares version 1.7.0 along with the |
| 64 | definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an |
| 65 | indication of the availability of this function. Reference counting in |
| 66 | \fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires |
| 67 | calls to the former function to match calls to the latter, is present since |
| 68 | c-ares version 1.10.0. |
| 69 | Earlier versions would deinitialize the library on the first call |
| 70 | to \fIares_library_cleanup()\fP. |
| 71 | .PP |
| 72 | Since the introduction of this function, it is absolutely mandatory to call it |
| 73 | for any Win32/64 program using c-ares. |
| 74 | .PP |
| 75 | Non-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 |
| 77 | a 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 |
| 82 | Yang Tse |
| 83 | .PP |
| 84 | Copyright 1998 by the Massachusetts Institute of Technology. |
| 85 | .br |
| 86 | Copyright (C) 2004-2009 by Daniel Stenberg. |