~ubuntu-branches/ubuntu/trusty/postfix/trusty

« back to all changes in this revision

Viewing changes to src/util/dict_dbm.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones, LaMont Jones, localization folks
  • Date: 2014-02-11 07:44:30 UTC
  • mfrom: (58.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140211074430-kwkoxdz0fbajn0fj
Tags: 2.11.0-1
[LaMont Jones]

* New upstream release: 2.11.0

[localization folks]

* l10n: Updated German translations.  Closes: #734893 (Helge Kreutzmann)

Show diffs side-by-side

added added

removed removed

Lines of Context:
414
414
    DICT_DBM *dict_dbm;
415
415
    struct stat st;
416
416
    DBM    *dbm;
417
 
    char   *dbm_path;
 
417
    char   *dbm_path = 0;
418
418
    int     lock_fd;
419
419
 
420
420
#ifdef HAVE_GDBM
422
422
                 path);
423
423
#endif
424
424
    /*
 
425
     * Let the optimizer worry about eliminating redundant code.
 
426
     */
 
427
#define DICT_DBM_OPEN_RETURN(d) { \
 
428
        DICT *__d = (d); \
 
429
        if (dbm_path != 0) \
 
430
            myfree(dbm_path); \
 
431
        return (__d); \
 
432
    } while (0)
 
433
 
 
434
    /*
425
435
     * Note: DICT_FLAG_LOCK is used only by programs that do fine-grained (in
426
436
     * the time domain) locking while accessing individual database records.
427
437
     * 
431
441
    if (dict_flags & DICT_FLAG_LOCK) {
432
442
        dbm_path = concatenate(path, ".dir", (char *) 0);
433
443
        if ((lock_fd = open(dbm_path, open_flags, 0644)) < 0)
434
 
            return (dict_surrogate(DICT_TYPE_DBM, path, open_flags, dict_flags,
435
 
                                   "open database %s: %m", dbm_path));
 
444
            DICT_DBM_OPEN_RETURN(dict_surrogate(DICT_TYPE_DBM, path,
 
445
                                                open_flags, dict_flags,
 
446
                                                "open database %s: %m",
 
447
                                                dbm_path));
436
448
        if (myflock(lock_fd, INTERNAL_LOCK, MYFLOCK_OP_SHARED) < 0)
437
449
            msg_fatal("shared-lock database %s for open: %m", dbm_path);
438
450
    }
441
453
     * XXX SunOS 5.x has no const in dbm_open() prototype.
442
454
     */
443
455
    if ((dbm = dbm_open((char *) path, open_flags, 0644)) == 0)
444
 
        return (dict_surrogate(DICT_TYPE_DBM, path, open_flags, dict_flags,
445
 
                               "open database %s.{dir,pag}: %m", path));
 
456
        DICT_DBM_OPEN_RETURN(dict_surrogate(DICT_TYPE_DBM, path,
 
457
                                            open_flags, dict_flags,
 
458
                                            "open database %s.{dir,pag}: %m",
 
459
                                            path));
446
460
 
447
461
    if (dict_flags & DICT_FLAG_LOCK) {
448
462
        if (myflock(lock_fd, INTERNAL_LOCK, MYFLOCK_OP_NONE) < 0)
487
501
    dict_dbm->key_buf = 0;
488
502
    dict_dbm->val_buf = 0;
489
503
 
490
 
    if ((dict_flags & DICT_FLAG_LOCK))
491
 
        myfree(dbm_path);
492
 
 
493
 
    return (DICT_DEBUG (&dict_dbm->dict));
 
504
    DICT_DBM_OPEN_RETURN(DICT_DEBUG (&dict_dbm->dict));
494
505
}
495
506
 
496
507
#endif