~ubuntu-branches/debian/sid/postfix/sid

« back to all changes in this revision

Viewing changes to src/util/dict_cdb.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones, LaMont Jones, localization folks
  • Date: 2014-02-11 07:44:30 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20140211074430-91tdwgjriazawdz4
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:
182
182
    char   *cdb_path;
183
183
    int     fd;
184
184
 
 
185
    /*
 
186
     * Let the optimizer worry about eliminating redundant code.
 
187
     */
 
188
#define DICT_CDBQ_OPEN_RETURN(d) { \
 
189
        DICT *__d = (d); \
 
190
        myfree(cdb_path); \
 
191
        return (__d); \
 
192
    } while (0)
 
193
 
185
194
    cdb_path = concatenate(path, CDB_SUFFIX, (char *) 0);
186
195
 
187
196
    if ((fd = open(cdb_path, O_RDONLY)) < 0)
188
 
        return (dict_surrogate(DICT_TYPE_CDB, path, O_RDONLY, dict_flags,
189
 
                               "open database %s: %m", cdb_path));
 
197
        DICT_CDBQ_OPEN_RETURN(dict_surrogate(DICT_TYPE_CDB, path,
 
198
                                           O_RDONLY, dict_flags,
 
199
                                         "open database %s: %m", cdb_path));
190
200
 
191
201
    dict_cdbq = (DICT_CDBQ *) dict_alloc(DICT_TYPE_CDB,
192
202
                                         cdb_path, sizeof(*dict_cdbq));
225
235
    if (dict_flags & DICT_FLAG_FOLD_FIX)
226
236
        dict_cdbq->dict.fold_buf = vstring_alloc(10);
227
237
 
228
 
    myfree(cdb_path);
229
 
    return (&dict_cdbq->dict);
 
238
    DICT_CDBQ_OPEN_RETURN(DICT_DEBUG (&dict_cdbq->dict));
230
239
}
231
240
 
232
241
/* dict_cdbm_update - add database entry, create mode */
330
339
    int     fd;
331
340
    struct stat st0, st1;
332
341
 
 
342
    /*
 
343
     * Let the optimizer worry about eliminating redundant code.
 
344
     */
 
345
#define DICT_CDBM_OPEN_RETURN(d) { \
 
346
        DICT *__d = (d); \
 
347
        if (cdb_path) \
 
348
            myfree(cdb_path); \
 
349
        if (tmp_path) \
 
350
            myfree(tmp_path); \
 
351
        return (__d); \
 
352
    } while (0)
 
353
 
333
354
    cdb_path = concatenate(path, CDB_SUFFIX, (char *) 0);
334
355
    tmp_path = concatenate(path, CDB_TMP_SUFFIX, (char *) 0);
335
356
 
342
363
     */
343
364
    for (;;) {
344
365
        if ((fd = open(tmp_path, O_RDWR | O_CREAT, 0644)) < 0)
345
 
            return (dict_surrogate(DICT_TYPE_CDB, path, O_RDWR, dict_flags,
346
 
                                   "open database %s: %m", tmp_path));
 
366
            DICT_CDBM_OPEN_RETURN(dict_surrogate(DICT_TYPE_CDB, path,
 
367
                                                 O_RDWR, dict_flags,
 
368
                                                 "open database %s: %m",
 
369
                                                 tmp_path));
347
370
        if (fstat(fd, &st0) < 0)
348
371
            msg_fatal("fstat(%s): %m", tmp_path);
349
372
 
383
406
    dict_cdbm->dict.update = dict_cdbm_update;
384
407
    dict_cdbm->cdb_path = cdb_path;
385
408
    dict_cdbm->tmp_path = tmp_path;
 
409
    cdb_path = tmp_path = 0;                    /* DICT_CDBM_OPEN_RETURN() */
386
410
    dict_cdbm->dict.owner.uid = st1.st_uid;
387
411
    dict_cdbm->dict.owner.status = (st1.st_uid != 0);
388
412
    close_on_exec(fd, CLOSE_ON_EXEC);
400
424
    if (dict_flags & DICT_FLAG_FOLD_FIX)
401
425
        dict_cdbm->dict.fold_buf = vstring_alloc(10);
402
426
 
403
 
    return (&dict_cdbm->dict);
 
427
    DICT_CDBM_OPEN_RETURN(DICT_DEBUG (&dict_cdbm->dict));
404
428
}
405
429
 
406
430
/* dict_cdb_open - open data base for query mode or create mode */