Blame ares_library_cleanup.3

Packit 514978
.\"
Packit 514978
.\" Copyright 1998 by the Massachusetts Institute of Technology.
Packit 514978
.\" Copyright (C) 2004-2009 by Daniel Stenberg
Packit 514978
.\"
Packit 514978
.\" Permission to use, copy, modify, and distribute this
Packit 514978
.\" software and its documentation for any purpose and without
Packit 514978
.\" fee is hereby granted, provided that the above copyright
Packit 514978
.\" notice appear in all copies and that both that copyright
Packit 514978
.\" notice and this permission notice appear in supporting
Packit 514978
.\" documentation, and that the name of M.I.T. not be used in
Packit 514978
.\" advertising or publicity pertaining to distribution of the
Packit 514978
.\" software without specific, written prior permission.
Packit 514978
.\" M.I.T. makes no representations about the suitability of
Packit 514978
.\" this software for any purpose.  It is provided "as is"
Packit 514978
.\" without express or implied warranty.
Packit 514978
.\"
Packit 514978
.TH ARES_LIBRARY_CLEANUP 3 "19 May 2009"
Packit 514978
.SH NAME
Packit 514978
ares_library_cleanup \- c-ares library deinitialization
Packit 514978
.SH SYNOPSIS
Packit 514978
.nf
Packit 514978
#include <ares.h>
Packit 514978
Packit 514978
void ares_library_cleanup(void)
Packit 514978
.fi
Packit 514978
.SH DESCRIPTION
Packit 514978
.PP
Packit 514978
The
Packit 514978
.B ares_library_cleanup
Packit 514978
function uninitializes the c-ares library, freeing all resources
Packit 514978
previously acquired by \fIares_library_init(3)\fP when the library
Packit 514978
was initialized, provided there was only one single previous call to
Packit 514978
\fIares_library_init(3)\fP. If there was more than one previous call to
Packit 514978
\fIares_library_init(3)\fP, this function uninitializes the c-ares
Packit 514978
library only if it is the call matching the call to
Packit 514978
\fIares_library_init(3)\fP which initialized the library
Packit 514978
(usually the very first call to \fIares_library_init(3)\fP).
Packit 514978
Other calls to \fIares_library_cleanup(3)\fP have no effect other than
Packit 514978
decrementing an internal counter.
Packit 514978
.PP
Packit 514978
This function must be called when the program using c-ares will
Packit 514978
no longer need any c-ares function. Once the program has called
Packit 514978
\fIares_library_cleanup(3)\fP sufficiently often such that the
Packit 514978
library is uninitialised, it shall not make any further call to any
Packit 514978
c-ares function.
Packit 514978
.PP
Packit 514978
This function does not cancel any pending c-ares lookups or requests
Packit 514978
previously done. Program  must use \fIares_cancel(3)\fP for this purpose.
Packit 514978
.PP
Packit 514978
.B This function is not thread safe.
Packit 514978
You have to call it once the program is about to terminate, but this call must
Packit 514978
be done once the program has terminated every single thread that it could have
Packit 514978
initiated. This is required to avoid potential race conditions in library
Packit 514978
deinitialization, and also due to the fact that \fIares_library_cleanup(3)\fP
Packit 514978
might call functions from other libraries that are thread unsafe, and could
Packit 514978
conflict with any other thread that is already using these other libraries.
Packit 514978
.PP
Packit 514978
Win32/64 application DLLs shall not call \fIares_library_cleanup(3)\fP from
Packit 514978
the DllMain function. Doing so will produce deadlocks and other problems.
Packit 514978
.SH AVAILABILITY
Packit 514978
This function was first introduced in c-ares version 1.7.0 along with the
Packit 514978
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an
Packit 514978
indication of the availability of this function. Reference counting in
Packit 514978
\fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires
Packit 514978
calls to the former function to match calls to the latter, is present since
Packit 514978
c-ares version 1.10.0.
Packit 514978
Earlier versions would deinitialize the library on the first call
Packit 514978
to \fIares_library_cleanup()\fP.
Packit 514978
.PP
Packit 514978
Since the introduction of this function, it is absolutely mandatory to call it
Packit 514978
for any Win32/64 program using c-ares.
Packit 514978
.PP
Packit 514978
Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
Packit 514978
\fIares_library_cleanup(3)\fP due to the fact that \fIcurrently\fP it is nearly
Packit 514978
a do-nothing function on non-Win32/64 platforms.
Packit 514978
.SH SEE ALSO
Packit 514978
.BR ares_library_init(3),
Packit 514978
.BR ares_cancel(3)
Packit 514978
.SH AUTHOR
Packit 514978
Yang Tse
Packit 514978
.PP
Packit 514978
Copyright 1998 by the Massachusetts Institute of Technology.
Packit 514978
.br
Packit 514978
Copyright (C) 2004-2009 by Daniel Stenberg.