Guntis, try the attached patch if you will.
But more importantly. a reliable workaround that won't require testing patches is to tune down the MAXCONNECTS parameter to 100 or so. This will prevent forked children from running too long. Guntis Bumburs wrote: > Anatoly wrote: >> Guntis Bumburs wrote: >> >>> Hello, >>> >>> I have a problem with dbmail on Freebsd. The situation is that dbmail >>> fills all the /tmp space (seems to not releasing used space/opened file) >>> and when it's full the imap daemon starts acting strange, postfix cant >>> flush new mails ... (pop daemon still works). >>> We have 2 installations with identical symptoms. >>> >>> 1. Our setup >>> FreeBSD 7.0-RELEASE-p7 >>> dbmail 2.2.11 >>> Mysql 5.0 hosted on dedicated server >>> >>> The problem happen rarely (once in a few month) could be because the low >>> traffic volume. >>> >>> #du -h /tmp >>> shows 88K used >>> >>> #df -h /tmp >>> shows 89M used >>> >>> # lsof | grep /tmp | grep dbmail >>> shows lots of open files .. >>> >>> ..... >>> dbmail-im 97091 nobody 18u VREG 0,92 82761 269 /tmp >>> (/dev/da0s1e) >>> dbmail-im 97091 nobody 19u VREG 0,92 82761 274 /tmp >>> (/dev/da0s1e) >>> dbmail-im 97091 nobody 20u VREG 0,92 1176746 275 /tmp >>> (/dev/da0s1e) >>> dbmail-im 97091 nobody 21u VREG 0,92 57917 279 /tmp >>> (/dev/da0s1e) >>> ..... >>> >>> summing the sizes seems to cerate these 89M >>> >>> >>> case Nr 2 is an installation for our client >>> FreeBSD 6.2-RELEASE-p11 >>> dbmail 2.2.11 >>> Mysql also hosted on other server >>> >>> It takes ~ 1 week to fill the /tmp >>> >>> #du -h /tmp shows 734K >>> # df -h /tmp shows 278M >>> #lsof | grep /tmp | grep dbmail >>> shows lots of open files >>> ..... >>> dbmail-im 97519 nobody 17u VREG 0,89 12840447 69 /tmp >>> (/dev/ad0s1e) >>> dbmail-im 97519 nobody 18u VREG 0,89 9689295 72 /tmp >>> (/dev/ad0s1e) >>> dbmail-im 97519 nobody 19u VREG 0,89 327779 78 /tmp >>> (/dev/ad0s1e) >>> dbmail-im 97519 nobody 20u VREG 0,89 447281 81 /tmp >>> (/dev/ad0s1e) >>> .... >>> >>> The probleam was also for dbmail 2.2.10 and some earlier versions >>> For now we have to periodically restart dbmail-imap daemon to release >>> /tmp. Also i have noticed that if i restart mysql (witch is on different >>> server) >>> /tmp is also freed. >>> >>> How can i be useful to help solve this problem? >>> >>> >>> Best Regards, >>> Guntis >>> >>> _______________________________________________ >>> DBmail mailing list >>> [email protected] >>> http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail >>> >>> >>> >> fsck /tmp >> > smtp-mx1# fsck /tmp > ** /dev/da0s1e (NO WRITE) > ** Last Mounted on /tmp > ** Phase 1 - Check Blocks and Sizes > ** Phase 2 - Check Pathnames > ** Phase 3 - Check Connectivity > ** Phase 4 - Check Reference Counts > UNREF FILE I=4 OWNER=nobody MODE=100600 > SIZE=1356 MTIME=Apr 23 07:12 2009 > CLEAR? no > > UNREF FILE I=13 OWNER=nobody MODE=100600 > SIZE=2586321 MTIME=Apr 23 08:41 2009 > CLEAR? no > > UNREF FILE I=14 OWNER=nobody MODE=100600 > SIZE=3874 MTIME=Apr 23 03:03 2009 > CLEAR? no > ...... > ...... > ** Phase 5 - Check Cyl groups > 104 files, 27824 used, 225991 free (199 frags, 28224 blocks, 0.1% > fragmentation) > > That is not a solution. I will have to umount /tmp (i can do it by force > or stop daemons witch is using /tmp and do normal umount). By stoping > dbmail-imap the problem is resolved. > So the problems reported by fsck is the effect of problems caused by dbmail. > > > _______________________________________________ > DBmail mailing list > [email protected] > http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail > -- ________________________________________________________________ Paul Stevens paul at nfg.nl NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31 The Netherlands________________________________http://www.nfg.nl
>From 3e09c23a8fd54bcc4d41dc1835bb48ba5272183f Mon Sep 17 00:00:00 2001 From: Paul J Stevens <[email protected]> Date: Thu, 23 Apr 2009 09:25:25 +0200 Subject: prevent filedescriptor leakage --- dbmail-message.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dbmail-message.c b/dbmail-message.c index 063b431..bfaff02 100644 --- a/dbmail-message.c +++ b/dbmail-message.c @@ -310,9 +310,6 @@ static int _set_content(struct DbmailMessage *self, const GString *content) self->raw = NULL; } - //self->raw = g_byte_array_new(); - //self->raw = g_byte_array_append(self->raw,(guint8 *)content->str, content->len+1); - //stream = g_mime_stream_mem_new_with_byte_array(self->raw); stream = g_mime_stream_mem_new_with_buffer(content->str, content->len+1); res = _set_content_from_stream(self, stream, DBMAIL_STREAM_PIPE); g_mime_stream_close(stream); @@ -332,7 +329,6 @@ static int _set_content_from_stream(struct DbmailMessage *self, GMimeStream *str GMimeParser *parser; gchar buf[MESSAGE_MAX_LINE_SIZE], *from = NULL; ssize_t getslen, putslen; - FILE *tmp; int res = 0; gboolean firstline; @@ -355,13 +351,20 @@ static int _set_content_from_stream(struct DbmailMessage *self, GMimeStream *str // stream -> bstream (buffer) -> fstream (filter) -> mstream (in-memory copy) bstream = g_mime_stream_buffer_new(stream,GMIME_STREAM_BUFFER_BLOCK_READ); -// mstream = g_mime_stream_mem_new(); - tmp = tmpfile(); + FILE *tmp = tmpfile(); + if (! tmp) { + int serr = errno; + TRACE(TRACE_ERROR, "opening tmpfile failed: %s", strerror(serr)); + res = 1; + break; + } + mstream = g_mime_stream_file_new(tmp); assert(mstream); fstream = g_mime_stream_filter_new_with_stream(mstream); + g_mime_stream_file_set_owner((GMimeStreamFile *)mstream, TRUE); filter = g_mime_filter_crlf_new(GMIME_FILTER_CRLF_DECODE,GMIME_FILTER_CRLF_MODE_CRLF_DOTS); g_mime_stream_filter_add((GMimeStreamFilter *) fstream, filter); -- 1.5.6.3
_______________________________________________ DBmail mailing list [email protected] http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail
