aboutsummaryrefslogtreecommitdiff
path: root/nss/nss_db
diff options
context:
space:
mode:
Diffstat (limited to 'nss/nss_db')
-rw-r--r--nss/nss_db/db-open.c111
-rw-r--r--nss/nss_db/dummy-db.h12
2 files changed, 62 insertions, 61 deletions
diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
index c3a0679485..75d39efaf6 100644
--- a/nss/nss_db/db-open.c
+++ b/nss/nss_db/db-open.c
@@ -118,6 +118,9 @@ internal_setent (const char *file, NSS_DB **dbp)
enum nss_status status = NSS_STATUS_SUCCESS;
int err;
void *db;
+ int fd;
+ int result;
+
if (*dbp == NULL)
{
@@ -138,77 +141,71 @@ internal_setent (const char *file, NSS_DB **dbp)
err = DL_CALL_FCT (libdb_db_open,
(file, DB_BTREE, DB_RDONLY, 0, NULL, NULL, &db));
+ if (err != 0)
+ {
+ __set_errno (err);
+ *dbp = NULL;
+ return err == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
+ }
+
/* Construct the object we pass up. */
*dbp = (NSS_DB *) malloc (sizeof (NSS_DB));
- if (*dbp != NULL)
+ if (*dbp == NULL)
+ return NSS_STATUS_UNAVAIL;
+
+ (*dbp)->db = db;
+
+ /* The functions are at different positions for the different
+ versions. Sigh. */
+ switch (libdb_version)
{
- (*dbp)->db = db;
-
- /* The functions are at different positions for the different
- versions. Sigh. */
- switch (libdb_version)
- {
- case db24:
- (*dbp)->close =
- (int (*) (void *, uint32_t)) ((struct db24 *) db)->close;
- (*dbp)->fd =
- (int (*) (void *, int *)) ((struct db24 *) db)->fd;
- (*dbp)->get =
- (int (*) (void *, void *, void *, void *, uint32_t))
- ((struct db24 *) db)->get;
- break;
- case db27:
- (*dbp)->close =
- (int (*) (void *, uint32_t)) ((struct db27 *) db)->close;
- (*dbp)->fd =
- (int (*) (void *, int *)) ((struct db27 *) db)->fd;
- (*dbp)->get =
- (int (*) (void *, void *, void *, void *, uint32_t))
- ((struct db27 *) db)->get;
- break;
- default:
- abort ();
- }
+ case db24:
+ (*dbp)->close =
+ (int (*) (void *, uint32_t)) ((struct db24 *) db)->close;
+ (*dbp)->fd =
+ (int (*) (void *, int *)) ((struct db24 *) db)->fd;
+ (*dbp)->get =
+ (int (*) (void *, void *, void *, void *, uint32_t))
+ ((struct db24 *) db)->get;
+ break;
+ case db27:
+ (*dbp)->close =
+ (int (*) (void *, uint32_t)) ((struct db27 *) db)->close;
+ (*dbp)->fd =
+ (int (*) (void *, int *)) ((struct db27 *) db)->fd;
+ (*dbp)->get =
+ (int (*) (void *, void *, void *, void *, uint32_t))
+ ((struct db27 *) db)->get;
+ break;
+ default:
+ abort ();
}
+ /* We have to make sure the file is `closed on exec'. */
+ err = DL_CALL_FCT ((*dbp)->fd, (db, &fd));
if (err != 0)
{
__set_errno (err);
- *dbp = NULL;
- status = err == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
+ result = -1;
}
else
{
- /* We have to make sure the file is `closed on exec'. */
- int fd;
- int result;
-
- err = DL_CALL_FCT ((*dbp)->fd, (db, &fd));
- if (err != 0)
- {
- __set_errno (err);
- result = -1;
- }
- else
- {
- int flags = result = fcntl (fd, F_GETFD, 0);
+ int flags = result = fcntl (fd, F_GETFD, 0);
- if (result >= 0)
- {
- flags |= FD_CLOEXEC;
- result = fcntl (fd, F_SETFD, flags);
- }
- }
- if (result < 0)
+ if (result >= 0)
{
- /* Something went wrong. Close the stream and return a
- failure. */
- DL_CALL_FCT ((*dbp)->close, (db, 0));
- status = NSS_STATUS_UNAVAIL;
+ flags |= FD_CLOEXEC;
+ result = fcntl (fd, F_SETFD, flags);
}
-
- if (result < 0)
- *dbp = NULL;
+ }
+ if (result < 0)
+ {
+ /* Something went wrong. Close the stream and return a
+ failure. */
+ DL_CALL_FCT ((*dbp)->close, (db, 0));
+ status = NSS_STATUS_UNAVAIL;
+ free (*dbp);
+ *dbp = NULL;
}
}
diff --git a/nss/nss_db/dummy-db.h b/nss/nss_db/dummy-db.h
index 600d51d984..6ac8b77bb1 100644
--- a/nss/nss_db/dummy-db.h
+++ b/nss/nss_db/dummy-db.h
@@ -70,6 +70,7 @@ struct db24
int (*put) (void *, void *, DBT *, DBT *, uint32_t);
int (*stat) (void *, void *, void *(*)(size_t), uint32_t);
int (*sync) (void *, uint32_t);
+ uint32_t flags;
};
@@ -99,6 +100,7 @@ struct db27
void *mutexp;
enum { dummy27 } type;
int byteswapped;
+ int saved_open_fd;
void *dbenv;
void *mp_dbenv;
void *internal;
@@ -114,9 +116,6 @@ struct db27
void *tqh_first;
void **tqh_last;
} active_queue;
- struct {
- void *lh_first;
- } handleq;
uint8_t fileid[20];
uint32_t log_fileid;
size_t pgsize;
@@ -130,9 +129,11 @@ struct db27
int (*del) (void *, void *, DBT *, uint32_t);
int (*fd) (void *, int *);
int (*get) (void *, void *, DBT *, DBT *, uint32_t);
+ int (*join) (void *, void **, uint32_t, void **);
int (*put) (void *, void *, DBT *, DBT *, uint32_t);
int (*stat) (void *, void *, void *(*)(size_t), uint32_t);
int (*sync) (void *, uint32_t);
+ uint32_t flags;
};
@@ -148,7 +149,10 @@ struct dbc27
uint32_t lid;
uint32_t locker;
DBT lock_dbt;
- uint32_t lock[14];
+ struct{
+ uint32_t pgno;
+ uint8_t fileid[20];
+ } lock;
size_t mylock;
DBT rkey;
DBT rdata;