git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Appendfile: release regex-match store every thousand files. Bug 3047
[exim.git]
/
src
/
src
/
transports
/
appendfile.c
diff --git
a/src/src/transports/appendfile.c
b/src/src/transports/appendfile.c
index e49f46be4bc2c8269451519e93788994d8784044..91b35307901e5eba28d6f9cf3dcfb735947d22fb 100644
(file)
--- a/
src/src/transports/appendfile.c
+++ b/
src/src/transports/appendfile.c
@@
-2,7
+2,7
@@
* Exim - an Internet mail transport agent *
*************************************************/
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) The Exim maintainers 2020 - 202
2
*/
+/* Copyright (c) The Exim maintainers 2020 - 202
3
*/
/* Copyright (c) University of Cambridge 1995 - 2020 */
/* See the file NOTICE for conditions of use and distribution. */
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Copyright (c) University of Cambridge 1995 - 2020 */
/* See the file NOTICE for conditions of use and distribution. */
/* SPDX-License-Identifier: GPL-2.0-or-later */
@@
-153,6
+153,10
@@
static const char *mailbox_formats[] = {
(!ob->quota_warn_threshold_is_percent || ob->quota_value > 0))
(!ob->quota_warn_threshold_is_percent || ob->quota_value > 0))
+/* Free memory allocated by PCRE2 every so often, because a recent version
+is now using 20kB for every match call */
+
+#define RESET_STORE_FILECNT 1000
/*************************************************
* Setup entry point *
/*************************************************
* Setup entry point *
@@
-502,7
+506,7
@@
Returns: nothing
*/
static void
*/
static void
-notify_comsat(
uschar *
user, off_t offset)
+notify_comsat(
const uschar *
user, off_t offset)
{
struct servent *sp;
host_item host;
{
struct servent *sp;
host_item host;
@@
-661,13
+665,14
@@
Returns: the sum of the sizes of the stattable files
off_t
check_dir_size(const uschar * dirname, int * countptr, const pcre2_code * re)
{
off_t
check_dir_size(const uschar * dirname, int * countptr, const pcre2_code * re)
{
-DIR *dir;
+DIR *
dir;
off_t sum = 0;
off_t sum = 0;
-int count = *countptr;
+int count = *countptr, lcount = RESET_STORE_FILECNT;
+rmark reset_point = store_mark();
if (!(dir = exim_opendir(dirname))) return 0;
if (!(dir = exim_opendir(dirname))) return 0;
-for (struct dirent *ent; ent = readdir(dir); )
+for (struct dirent *
ent; ent = readdir(dir); )
{
uschar * path, * name = US ent->d_name;
struct stat statbuf;
{
uschar * path, * name = US ent->d_name;
struct stat statbuf;
@@
-675,6
+680,11
@@
for (struct dirent *ent; ent = readdir(dir); )
if (Ustrcmp(name, ".") == 0 || Ustrcmp(name, "..") == 0) continue;
count++;
if (Ustrcmp(name, ".") == 0 || Ustrcmp(name, "..") == 0) continue;
count++;
+ if (--lcount == 0)
+ {
+ store_reset(reset_point); reset_point = store_mark();
+ lcount = RESET_STORE_FILECNT;
+ }
/* If there's a regex, try to find the size using it */
/* If there's a regex, try to find the size using it */
@@
-726,6
+736,7
@@
DEBUG(D_transport)
debug_printf("check_dir_size: dir=%s sum=" OFF_T_FMT " count=%d\n", dirname,
sum, count);
debug_printf("check_dir_size: dir=%s sum=" OFF_T_FMT " count=%d\n", dirname,
sum, count);
+store_reset(reset_point);
*countptr = count;
return sum;
}
*countptr = count;
return sum;
}