X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fdbstuff.h;h=93c715ac2f27f33568870f57875777c43500c600;hb=ab6f5da3dfe80ed83827fd2f9e3e72c86d103649;hp=2cbd8ca636324f14f437c5eaaba6115627ef630a;hpb=19897d528de779d4d3804fd7d10c235e8b50a53e;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/dbstuff.h b/src/src/dbstuff.h index 2cbd8ca63..93c715ac2 100644 --- a/src/src/dbstuff.h +++ b/src/src/dbstuff.h @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/dbstuff.h,v 1.7 2007/08/29 14:02:22 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2007 */ +/* Copyright (c) University of Cambridge 1995 - 2009 */ /* See the file NOTICE for conditions of use and distribution. */ /* This header file contains macro definitions so that a variety of DBM @@ -66,7 +64,7 @@ tdb_traverse to be called) */ /* EXIM_DBCREATE_CURSOR - initialize for scanning operation */ #define EXIM_DBCREATE_CURSOR(db, cursor) { \ - *(cursor) = malloc(sizeof(TDB_DATA)); (*(cursor))->dptr = NULL; } + *(cursor) = store_malloc(sizeof(TDB_DATA)); (*(cursor))->dptr = NULL; } /* EXIM_DBSCAN - This is complicated because we have to free the last datum free() must not die when passed NULL */ @@ -300,6 +298,17 @@ before use, but we don't have to free anything after reading data. */ /* Some text for messages */ #define EXIM_DBTYPE "db (v1)" +/* When scanning, for the non-first case we historically just passed 0 +as the flags field and it worked. On FreeBSD 8 it no longer works and +instead leads to memory exhaustion. The man-page on FreeBSD says to use +R_NEXT, but this 1.x is a historical fallback and I've no idea how portable +the use of that flag is; so the solution is to define R_NEXT here if it's not +already defined, with a default value of 0 because that's what we've always +before been able to pass successfully. */ +#ifndef R_NEXT +#define R_NEXT 0 +#endif + /* Access functions */ /* EXIM_DBOPEN - sets *dbpp to point to an EXIM_DB, NULL if failed */ @@ -331,7 +340,7 @@ before use, but we don't have to free anything after reading data. */ /* EXIM_DBSCAN - returns TRUE if data is returned, FALSE at end */ #define EXIM_DBSCAN(db, key, data, first, cursor) \ - ((db)->seq(db, &key, &data, (first? R_FIRST : 0)) == 0) + ((db)->seq(db, &key, &data, (first? R_FIRST : R_NEXT)) == 0) /* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). Make it refer to cursor, to keep picky compilers happy. */ @@ -643,5 +652,14 @@ typedef struct { double rate; /* Smoothed sending rate at that time */ } dbdata_ratelimit; +/* Same as above, plus a Bloom filter for uniquifying events. */ + +typedef struct { + dbdata_ratelimit dbd; + time_t bloom_epoch; /* When the Bloom filter was last reset */ + unsigned bloom_size; /* Number of bytes in the Bloom filter */ + uschar bloom[40]; /* Bloom filter which may be larger than this */ +} dbdata_ratelimit_unique; + /* End of dbstuff.h */