From 5a0782d4d11ed0d13852a3b311781388d63250fc Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Thu, 22 Jan 2015 12:44:48 -0500 Subject: pacman: properly set threads option Signed-off-by: Andrew Gregory --- src/pacman/conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 59c38696..93473465 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -105,6 +105,7 @@ config_t *config_new(void) newconfig->logmask = ALPM_LOG_ERROR | ALPM_LOG_WARNING; newconfig->configfile = strdup(CONFFILE); newconfig->deltaratio = 0.0; + newconfig->threads = 1; if(alpm_capabilities() & ALPM_CAPABILITY_SIGNATURES) { newconfig->siglevel = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL | ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; @@ -618,14 +619,14 @@ static int _parse_options(const char *key, char *value, } threads = strtoul(value, &endptr, 10); - if(*endptr != '\0' || threads < 0) { + if(*endptr != '\0' || threads < 1 || threads > UINT_MAX) { pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: invalid value for '%s' : '%s'\n"), file, linenum, "Threads", value); return 1; } config->threads = threads; - pm_printf(ALPM_LOG_DEBUG, "config: Threads = %f\n", threads); + pm_printf(ALPM_LOG_DEBUG, "config: Threads = %lu\n", threads); } else { pm_printf(ALPM_LOG_WARNING, _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), @@ -834,6 +835,7 @@ static int setup_libalpm(void) alpm_option_set_checkspace(handle, config->checkspace); alpm_option_set_usesyslog(handle, config->usesyslog); alpm_option_set_deltaratio(handle, config->deltaratio); + alpm_option_set_thread_count(handle, config->threads); alpm_option_set_ignorepkgs(handle, config->ignorepkg); alpm_option_set_ignoregroups(handle, config->ignoregrp); -- cgit v1.2.3-24-g4f1b