From 4b982619a3a275e7ee9d607c7e3eb9a348f8fe6b Mon Sep 17 00:00:00 2001 From: "graham.gower" Date: Mon, 16 Nov 2009 00:32:24 +0000 Subject: [PATCH] atexit() isn't really appropriate for a library. git-svn-id: http://opkg.googlecode.com/svn/trunk@313 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg/libopkg.c | 3 +++ libopkg/opkg.c | 3 +++ libopkg/opkg_download.c | 9 +-------- libopkg/opkg_download.h | 3 +++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libopkg/libopkg.c b/libopkg/libopkg.c index c73c4a3..37770eb 100644 --- a/libopkg/libopkg.c +++ b/libopkg/libopkg.c @@ -96,6 +96,9 @@ opkg_op (int argc, char *argv[]) err = opkg_cmd_exec (cmd, &opkg_conf, argc - optind, (const char **) (argv + optind), NULL); +#ifdef HAVE_CURL + opkg_curl_cleanup(); +#endif opkg_conf_deinit (&opkg_conf); return err; diff --git a/libopkg/opkg.c b/libopkg/opkg.c index 785d588..aea87fc 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -211,6 +211,9 @@ opkg_free (opkg_t *opkg) { opkg_assert (opkg != NULL); +#ifdef HAVE_CURL + opkg_curl_cleanup(); +#endif opkg_conf_deinit (opkg->conf); args_deinit (opkg->args); free (opkg->options); diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index ab21ae9..be3ae2a 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -68,7 +68,6 @@ static X509_STORE *setup_verify(opkg_conf_t *conf, char *CAfile, char *CApath); * each time */ static CURL *curl = NULL; -static void opkg_curl_cleanup(void); static CURL *opkg_curl_init(opkg_conf_t *conf, curl_progress_func cb, void *data); #endif @@ -530,7 +529,7 @@ end: #endif #ifdef HAVE_CURL -static void opkg_curl_cleanup(void){ +void opkg_curl_cleanup(void){ if(curl != NULL){ curl_easy_cleanup (curl); curl = NULL; @@ -635,12 +634,6 @@ static CURL *opkg_curl_init(opkg_conf_t *conf, curl_progress_func cb, void *data curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd); free (userpwd); } - - /* add curl cleanup callback */ - if(!atexit(opkg_curl_cleanup)){ - opkg_message(conf,OPKG_DEBUG, "Failed to register atexit curl cleanup function\n"); - } - } curl_easy_setopt (curl, CURLOPT_NOPROGRESS, (cb == NULL)); diff --git a/libopkg/opkg_download.h b/libopkg/opkg_download.h index 39cd9a6..10347ca 100644 --- a/libopkg/opkg_download.h +++ b/libopkg/opkg_download.h @@ -32,4 +32,7 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir); int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **namep); int opkg_verify_file (opkg_conf_t *conf, char *text_file, char *sig_file); +#ifdef HAVE_CURL +void opkg_curl_cleanup(void); +#endif #endif -- 2.25.1