@@ -72,6 +72,20 @@ static struct authnone_private {
u_int mcnt;
} *authnone_private;
+__attribute__((destructor))
+static void
+authnone_cleanup(void)
+{
+ extern mutex_t authnone_lock;
+
+ mutex_lock(&authnone_lock);
+ if (authnone_private) {
+ free(authnone_private);
+ authnone_private = NULL;
+ }
+ mutex_unlock(&authnone_lock);
+}
+
AUTH *
authnone_create()
{
@@ -130,6 +130,18 @@ struct cu_data {
char cu_inbuf[1];
};
+__attribute__((destructor))
+static void
+clnt_vc_cleanup(void)
+{
+ mutex_lock(&clnt_fd_lock);
+ if (dg_fd_locks) {
+ mem_free(dg_fd_locks, sizeof(*dg_fd_locks));
+ dg_fd_locks = NULL;
+ }
+ mutex_unlock(&clnt_fd_lock);
+}
+
/*
* Connection less client creation returns with client handle parameters.
* Default options are set, which the user can change using clnt_control().
@@ -158,6 +158,18 @@ static const char clnt_vc_errstr[] = "%s : %s";
static const char clnt_vc_str[] = "clnt_vc_create";
static const char __no_mem_str[] = "out of memory";
+__attribute__((destructor))
+static void
+clnt_vc_cleanup(void)
+{
+ mutex_lock(&clnt_fd_lock);
+ if (vc_fd_locks) {
+ mem_free(vc_fd_locks, sizeof(*vc_fd_locks));
+ vc_fd_locks = NULL;
+ }
+ mutex_unlock(&clnt_fd_lock);
+}
+
/*
* Create a client handle for a connection.
* Default options are set, which the user can change using clnt_control()'s.
@@ -85,6 +85,25 @@ static void __xprt_do_unregister (SVCXPRT * xprt, bool_t dolock);
/* *************** SVCXPRT related stuff **************** */
+__attribute__((destructor))
+static void
+xprt_cleanup(void)
+{
+ rwlock_wrlock (&svc_fd_lock);
+ if (__svc_xports != NULL)
+ {
+ free (__svc_xports);
+ __svc_xports = NULL;
+ }
+ if (svc_pollfd != NULL)
+ {
+ free (svc_pollfd);
+ svc_pollfd = NULL;
+ svc_max_pollfd = 0;
+ }
+ rwlock_unlock (&svc_fd_lock);
+}
+
/*
* Activate a transport handle.
*/
Signed-off-by: Doug Nazar <nazard@nazar.ca> --- src/auth_none.c | 14 ++++++++++++++ src/clnt_dg.c | 12 ++++++++++++ src/clnt_vc.c | 12 ++++++++++++ src/svc.c | 19 +++++++++++++++++++ 4 files changed, 57 insertions(+)