]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
snapshot-20001030
authorWietse Venema <wietse@porcupine.org>
Mon, 30 Oct 2000 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:26:53 +0000 (06:26 +0000)
postfix/HISTORY
postfix/src/global/mail_version.h
postfix/src/util/dict_db.c
postfix/src/util/dict_open.c

index 96dceb72f3c5a708042c19a35e2b249507db91b6..127aecf49fe6507848194479d6d39c51478ec6f8 100644 (file)
@@ -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.
index c919efe231494c772f474479b03d1f69c8105ebc..6b9b33f29d8adfe7fe15138a9d42e1c1051f3689 100644 (file)
@@ -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
index 9044045752463749ad2f5e591d0323a1e51787dd..95a3e305df97587ac2b0db18013a12ba4f5d37c2 100644 (file)
@@ -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;
index 454b28719de2706db1d82d6f681cd51c8ea268bb..e06c9daa156420668aa16b7507647634ded07c89 100644 (file)
@@ -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;