1ARES_LIBRARY_CLEANUP(3)    Library Functions Manual    ARES_LIBRARY_CLEANUP(3)
2
3
4

NAME

6       ares_library_cleanup - c-ares library deinitialization
7

SYNOPSIS

9       #include <ares.h>
10
11       void ares_library_cleanup(void)
12
13       cc file.c -lcares
14

DESCRIPTION

16       The  ares_library_cleanup  function  uninitializes  the c-ares library,
17       freeing all resources previously acquired by ares_library_init(3)  when
18       the  library was initialized, provided there was only one single previ‐
19       ous call to ares_library_init(3). If there was more than  one  previous
20       call  to  ares_library_init(3),  this function uninitializes the c-ares
21       library   only   if   it   is   the   call   matching   the   call   to
22       ares_library_init(3)  which  initialized  the library (usually the very
23       first    call    to    ares_library_init(3)).     Other    calls     to
24       ares_library_cleanup(3)  have  no  effect  other  than  decrementing an
25       internal counter.
26
27       This function must be called when the  program  using  c-ares  will  no
28       longer   need   any  c-ares  function.  Once  the  program  has  called
29       ares_library_cleanup(3) sufficiently often such  that  the  library  is
30       uninitialised,  it  shall not make any further call to any c-ares func‐
31       tion.
32
33       This function does not cancel any pending c-ares  lookups  or  requests
34       previously done. Program  must use ares_cancel(3) for this purpose.
35
36       This function is not thread safe.  You have to call it once the program
37       is about to terminate, but this call must be done once the program  has
38       terminated  every  single  thread that it could have initiated. This is
39       required to avoid potential race conditions  in  library  deinitializa‐
40       tion,  and also due to the fact that ares_library_cleanup(3) might call
41       functions from other libraries that are thread unsafe, and  could  con‐
42       flict  with  any  other  thread  that  is  already  using  these  other
43       libraries.
44
45       Win32/64 application DLLs shall not call  ares_library_cleanup(3)  from
46       the  DllMain  function. Doing so will produce deadlocks and other prob‐
47       lems.
48

AVAILABILITY

50       This function was first introduced in c-ares version 1.7.0  along  with
51       the  definition  of preprocessor symbol CARES_HAVE_ARES_LIBRARY_CLEANUP
52       as an indication of the availability of this function. Reference count‐
53       ing  in  ares_library_init() and ares_library_cleanup(), which requires
54       calls to the former function to match calls to the latter,  is  present
55       since  c-ares  version 1.10.0.  Earlier versions would deinitialize the
56       library on the first call to ares_library_cleanup().
57
58       Since the introduction of this function, it is absolutely mandatory  to
59       call it for any Win32/64 program using c-ares.
60
61       Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
62       ares_library_cleanup(3) due to the fact that currently it is  nearly  a
63       do-nothing function on non-Win32/64 platforms.
64

SEE ALSO

66       ares_library_init(3), ares_cancel(3)
67

AUTHOR

69       Yang Tse
70
71       Copyright 1998 by the Massachusetts Institute of Technology.
72       Copyright (C) 2004-2009 by Daniel Stenberg.
73
74
75
76                                  19 May 2009          ARES_LIBRARY_CLEANUP(3)
Impressum