Make sure that only 1 thread can inject the vpkg config files.

This commit is contained in:
Juan RP 2013-06-14 12:31:43 +02:00
parent 9d80524a34
commit ee9b799822

View File

@ -30,9 +30,11 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
#include <pthread.h>
#include "xbps_api_impl.h" #include "xbps_api_impl.h"
static pthread_mutex_t cfg_mtx = PTHREAD_MUTEX_INITIALIZER;
static bool cfg_vpkgs_init; static bool cfg_vpkgs_init;
static prop_dictionary_t static prop_dictionary_t
@ -240,8 +242,10 @@ vpkg_user_conf(struct xbps_handle *xhp,
return NULL; return NULL;
/* inject virtual packages from sysconfdir */ /* inject virtual packages from sysconfdir */
pthread_mutex_lock(&cfg_mtx);
if (!cfg_vpkgs_init) if (!cfg_vpkgs_init)
config_inject_vpkgs(xhp); config_inject_vpkgs(xhp);
pthread_mutex_unlock(&cfg_mtx);
if ((cnt = cfg_size(xhp->cfg, "virtual-package")) == 0) { if ((cnt = cfg_size(xhp->cfg, "virtual-package")) == 0) {
/* no virtual packages configured */ /* no virtual packages configured */