ares_library_cleanup.3 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include <ares.h>
  23. void ares_library_cleanup(void)
  24. .fi
  25. .SH DESCRIPTION
  26. .PP
  27. The
  28. .B ares_library_cleanup
  29. function uninitializes the c-ares library, freeing all resources
  30. previously acquired by \fIares_library_init(3)\fP when the library
  31. was initialized, provided there was only one single previous call to
  32. \fIares_library_init(3)\fP. If there was more than one previous call to
  33. \fIares_library_init(3)\fP, this function uninitializes the c-ares
  34. library only if it is the call matching the call to
  35. \fIares_library_init(3)\fP which initialized the library
  36. (usually the very first call to \fIares_library_init(3)\fP).
  37. Other calls to \fIares_library_cleanup(3)\fP have no effect other than
  38. decrementing an internal counter.
  39. .PP
  40. This function must be called when the program using c-ares will
  41. no longer need any c-ares function. Once the program has called
  42. \fIares_library_cleanup(3)\fP sufficiently often such that the
  43. library is uninitialised, it shall not make any further call to any
  44. c-ares function.
  45. .PP
  46. This function does not cancel any pending c-ares lookups or requests
  47. previously done. Program must use \fIares_cancel(3)\fP for this purpose.
  48. .PP
  49. .B This function is not thread safe.
  50. You have to call it once the program is about to terminate, but this call must
  51. be done once the program has terminated every single thread that it could have
  52. initiated. This is required to avoid potential race conditions in library
  53. deinitialization, and also due to the fact that \fIares_library_cleanup(3)\fP
  54. might call functions from other libraries that are thread unsafe, and could
  55. conflict with any other thread that is already using these other libraries.
  56. .PP
  57. Win32/64 application DLLs shall not call \fIares_library_cleanup(3)\fP from
  58. the DllMain function. Doing so will produce deadlocks and other problems.
  59. .SH AVAILABILITY
  60. This function was first introduced in c-ares version 1.7.0 along with the
  61. definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an
  62. indication of the availability of this function. Reference counting in
  63. \fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires
  64. calls to the former function to match calls to the latter, is present since
  65. c-ares version 1.10.0.
  66. Earlier versions would deinitialize the library on the first call
  67. to \fIares_library_cleanup()\fP.
  68. .PP
  69. Since the introduction of this function, it is absolutely mandatory to call it
  70. for any Win32/64 program using c-ares.
  71. .PP
  72. Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
  73. \fIares_library_cleanup(3)\fP due to the fact that \fIcurrently\fP it is nearly
  74. a do-nothing function on non-Win32/64 platforms.
  75. .SH SEE ALSO
  76. .BR ares_library_init(3),
  77. .BR ares_cancel(3)
  78. .SH AUTHOR
  79. Yang Tse
  80. .PP
  81. Copyright 1998 by the Massachusetts Institute of Technology.
  82. .br
  83. Copyright (C) 2004-2009 by Daniel Stenberg.