summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-03 12:06:25 -0500
committerDan McGee <dan@archlinux.org>2011-06-03 12:06:25 -0500
commitc47d25d74be9ce1fbbfb8577687d9f37ba38d98b (patch)
tree6f09de2695287954f8f83a6dae22e00463f31e78
parent2102d1a2eb6cb9db674fd76aa7aa3192befad733 (diff)
downloadpacman-c47d25d74be9ce1fbbfb8577687d9f37ba38d98b.tar.xz
Add handle attribute to pmdb_t struct
This is the first step in a long process to remove our dependence on the global handle variable we currently share in libalpm, with the goal to make things a bit more thread-safe and re-entrant. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/be_local.c1
-rw-r--r--lib/libalpm/be_sync.c1
-rw-r--r--lib/libalpm/db.h1
-rw-r--r--lib/libalpm/handle.h4
5 files changed, 6 insertions, 2 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 5af843c4..bc06cc09 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -74,6 +74,7 @@ typedef enum _pgp_verify_t {
* Structures
*/
+typedef struct __pmhandle_t pmhandle_t;
typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t;
typedef struct __pmdelta_t pmdelta_t;
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index fc138e39..c470cbad 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -952,6 +952,7 @@ pmdb_t *_alpm_db_register_local(void)
RET_ERR(PM_ERR_DB_CREATE, NULL);
}
db->ops = &local_db_ops;
+ db->handle = handle;
handle->db_local = db;
return db;
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 77c9207d..1d633982 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -513,6 +513,7 @@ pmdb_t *_alpm_db_register_sync(const char *treename)
RET_ERR(PM_ERR_DB_CREATE, NULL);
}
db->ops = &sync_db_ops;
+ db->handle = handle;
handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
return db;
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 399e2d56..8d92bd2d 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -53,6 +53,7 @@ struct db_operations {
/* Database */
struct __pmdb_t {
+ pmhandle_t *handle;
char *treename;
/* do not access directly, use _alpm_db_path(db) for lazy access */
char *_path;
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index aa00b6f0..08dbe739 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -33,7 +33,7 @@
#include <curl/curl.h>
#endif
-typedef struct _pmhandle_t {
+struct __pmhandle_t {
/* internal usage */
pmdb_t *db_local; /* local db pointer */
alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
@@ -73,7 +73,7 @@ typedef struct _pmhandle_t {
int usedelta; /* Download deltas if possible */
int checkspace; /* Check disk space before installing */
pgp_verify_t sigverify; /* Default signature verification level */
-} pmhandle_t;
+};
/* global handle variable */
extern pmhandle_t *handle;