From: Wietse Venema Date: Mon, 30 Oct 2000 05:00:00 +0000 (-0500) Subject: snapshot-20001030 X-Git-Tag: v20010228~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5583b224b4851b1861504e221696bc5ce7fa8754;p=thirdparty%2Fpostfix.git snapshot-20001030 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 96dceb72f..127aecf49 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -4418,3 +4418,9 @@ Apologies for any names omitted. Feature: added UNIX-domain support to the smtpstone test programs in order to test the LMTP client UNIX-domain support. + +20001039 + + Bugfix: further testing in preparation for 19991231-pl10 + revealed that the DB map code was now broken for every + platform. diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index c919efe23..6b9b33f29 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-20001029" +#define DEF_MAIL_VERSION "Snapshot-20001030" extern char *var_mail_version; /* LICENSE diff --git a/postfix/src/util/dict_db.c b/postfix/src/util/dict_db.c index 904404575..95a3e305d 100644 --- a/postfix/src/util/dict_db.c +++ b/postfix/src/util/dict_db.c @@ -122,9 +122,9 @@ static int sanitize(int status) */ switch (status) { - case DB_NOTFOUND: /* get, del */ - case DB_KEYEXIST: /* put */ - return (1); /* non-fatal */ + case DB_NOTFOUND: /* get, del */ + case DB_KEYEXIST: /* put */ + return (1); /* non-fatal */ case 0: return (0); /* success */ @@ -313,6 +313,9 @@ static int dict_db_delete(DICT *dict, const char *name) if (status == 0) dict->flags &= ~DICT_FLAG_TRY1NULL; } + if (dict->flags & DICT_FLAG_SYNC_UPDATE) + if (DICT_DB_SYNC(db, 0) < 0) + msg_fatal("%s: flush dictionary: %m", dict_db->path); /* * Release the exclusive lock. @@ -421,6 +424,7 @@ static DICT *dict_db_open(const char *path, int open_flags, int type, DB *db; char *db_path; int lock_fd = -1; + int dbfd; #if DB_VERSION_MAJOR > 1 int db_flags; @@ -429,6 +433,13 @@ static DICT *dict_db_open(const char *path, int open_flags, int type, db_path = concatenate(path, ".db", (char *) 0); + if (dict_flags & DICT_FLAG_LOCK) { + if ((lock_fd = open(db_path, open_flags, 0644)) < 0) + msg_fatal("open database %s: %m", db_path); + if (myflock(lock_fd, MYFLOCK_SHARED) < 0) + msg_fatal("shared-lock database %s for open: %m", db_path); + } + /* * Use the DB 1.x programming interface. This is the default interface * with 4.4BSD systems. It is also available via the db_185 compatibility @@ -438,7 +449,7 @@ static DICT *dict_db_open(const char *path, int open_flags, int type, #if DB_VERSION_MAJOR < 2 if ((db = dbopen(db_path, open_flags, 0644, type, tweak)) == 0) msg_fatal("open database %s: %m", db_path); - lock_fd = db->fd(db); + dbfd = db->fd(db); #endif /* @@ -456,7 +467,7 @@ static DICT *dict_db_open(const char *path, int open_flags, int type, msg_fatal("open database %s: %m", db_path); if (db == 0) msg_panic("db_open null result"); - if ((errno = db->fd(db, &lock_fd)) != 0) + if ((errno = db->fd(db, &dbfd)) != 0) msg_fatal("get database file descriptor: %m"); #endif @@ -481,9 +492,15 @@ static DICT *dict_db_open(const char *path, int open_flags, int type, msg_fatal("set DB hash element count %d: %m", DICT_DB_NELM); if ((errno = db->open(db, db_path, 0, type, db_flags, 0644)) != 0) msg_fatal("open database %s: %m", db_path); - if ((errno = db->fd(db, &lock_fd)) != 0) + if ((errno = db->fd(db, &dbfd)) != 0) msg_fatal("get database file descriptor: %m"); #endif + if (dict_flags & DICT_FLAG_LOCK) { + if (myflock(lock_fd, MYFLOCK_NONE) < 0) + msg_fatal("unlock database %s for open: %m", db_path); + if (close(lock_fd) < 0) + msg_fatal("close database %s: %m", db_path); + } dict_db = (DICT_DB *) mymalloc(sizeof(*dict_db)); dict_db->dict.lookup = dict_db_lookup; @@ -491,7 +508,7 @@ static DICT *dict_db_open(const char *path, int open_flags, int type, dict_db->dict.delete = dict_db_delete; dict_db->dict.sequence = dict_db_sequence; dict_db->dict.close = dict_db_close; - dict_db->dict.fd = lock_fd; + dict_db->dict.fd = dbfd; if (fstat(dict_db->dict.fd, &st) < 0) msg_fatal("dict_db_open: fstat: %m"); dict_db->dict.mtime = st.st_mtime; diff --git a/postfix/src/util/dict_open.c b/postfix/src/util/dict_open.c index 454b28719..e06c9daa1 100644 --- a/postfix/src/util/dict_open.c +++ b/postfix/src/util/dict_open.c @@ -336,7 +336,7 @@ static NORETURN usage(char *myname) msg_fatal("usage: %s type:file read|write|create", myname); } -main(int argc, char **argv) +int main(int argc, char **argv) { VSTRING *keybuf = vstring_alloc(1); DICT *dict;