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>
This commit is contained in:
Dan McGee 2011-06-03 12:06:25 -05:00
parent 2102d1a2eb
commit c47d25d74b
5 changed files with 6 additions and 2 deletions

View file

@ -74,6 +74,7 @@ typedef enum _pgp_verify_t {
* Structures * Structures
*/ */
typedef struct __pmhandle_t pmhandle_t;
typedef struct __pmdb_t pmdb_t; typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t; typedef struct __pmpkg_t pmpkg_t;
typedef struct __pmdelta_t pmdelta_t; typedef struct __pmdelta_t pmdelta_t;

View file

@ -952,6 +952,7 @@ pmdb_t *_alpm_db_register_local(void)
RET_ERR(PM_ERR_DB_CREATE, NULL); RET_ERR(PM_ERR_DB_CREATE, NULL);
} }
db->ops = &local_db_ops; db->ops = &local_db_ops;
db->handle = handle;
handle->db_local = db; handle->db_local = db;
return db; return db;

View file

@ -513,6 +513,7 @@ pmdb_t *_alpm_db_register_sync(const char *treename)
RET_ERR(PM_ERR_DB_CREATE, NULL); RET_ERR(PM_ERR_DB_CREATE, NULL);
} }
db->ops = &sync_db_ops; db->ops = &sync_db_ops;
db->handle = handle;
handle->dbs_sync = alpm_list_add(handle->dbs_sync, db); handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
return db; return db;

View file

@ -53,6 +53,7 @@ struct db_operations {
/* Database */ /* Database */
struct __pmdb_t { struct __pmdb_t {
pmhandle_t *handle;
char *treename; char *treename;
/* do not access directly, use _alpm_db_path(db) for lazy access */ /* do not access directly, use _alpm_db_path(db) for lazy access */
char *_path; char *_path;

View file

@ -33,7 +33,7 @@
#include <curl/curl.h> #include <curl/curl.h>
#endif #endif
typedef struct _pmhandle_t { struct __pmhandle_t {
/* internal usage */ /* internal usage */
pmdb_t *db_local; /* local db pointer */ pmdb_t *db_local; /* local db pointer */
alpm_list_t *dbs_sync; /* List of (pmdb_t *) */ alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
@ -73,7 +73,7 @@ typedef struct _pmhandle_t {
int usedelta; /* Download deltas if possible */ int usedelta; /* Download deltas if possible */
int checkspace; /* Check disk space before installing */ int checkspace; /* Check disk space before installing */
pgp_verify_t sigverify; /* Default signature verification level */ pgp_verify_t sigverify; /* Default signature verification level */
} pmhandle_t; };
/* global handle variable */ /* global handle variable */
extern pmhandle_t *handle; extern pmhandle_t *handle;