handle: Add CURL* and CURLcode vars to struct
Adding the CURLcode is necessary in order to return an error string from pm_error. Unlike libfetch, curl returns numerical error numbers and does not maintain a staticly allocated string with the last error generated. Adding the curl object itself to the handle is advantageous (and encouraged by curl_easy_perform(3)) because the handle is reusable for successive operations. This cuts back on overhead when downloading multiple files in a single transaction. Signed-off-by: Dave Reisner <d@falconindy.com>
This commit is contained in:
parent
75bfe825fc
commit
278c847106
|
@ -71,6 +71,11 @@ void _alpm_handle_free(pmhandle_t *handle)
|
|||
closelog();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBCURL
|
||||
/* release curl handle */
|
||||
curl_easy_cleanup(handle->curl);
|
||||
#endif
|
||||
|
||||
/* free memory */
|
||||
_alpm_trans_free(handle->trans);
|
||||
FREE(handle->root);
|
||||
|
@ -85,6 +90,7 @@ void _alpm_handle_free(pmhandle_t *handle)
|
|||
FREELIST(handle->ignorepkg);
|
||||
FREELIST(handle->ignoregrp);
|
||||
FREE(handle);
|
||||
|
||||
}
|
||||
|
||||
alpm_cb_log SYMEXPORT alpm_option_get_logcb()
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#include "alpm.h"
|
||||
#include "trans.h"
|
||||
|
||||
#ifdef HAVE_LIBCURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
typedef struct _pmhandle_t {
|
||||
/* internal usage */
|
||||
pmdb_t *db_local; /* local db pointer */
|
||||
|
@ -37,6 +41,12 @@ typedef struct _pmhandle_t {
|
|||
FILE *lckstream; /* lock file stream pointer if one exists */
|
||||
pmtrans_t *trans;
|
||||
|
||||
#ifdef HAVE_LIBCURL
|
||||
/* libcurl handle */
|
||||
CURL *curl; /* reusable curl_easy handle */
|
||||
CURLcode curlerr; /* last error produced by curl */
|
||||
#endif
|
||||
|
||||
/* callback functions */
|
||||
alpm_cb_log logcb; /* Log callback function */
|
||||
alpm_cb_download dlcb; /* Download callback function */
|
||||
|
|
Loading…
Reference in New Issue