[PATCH] LMAIL: preventing of excessive hdd access
Stephan Mueller <[email protected]>
| Newsgroups | gmane.mail.xmail.general |
|---|---|
| Message-ID | <1274866966.30052.14.camel@tauon> |
Hi, please see attached patch for LMAIL. It stops from creating tmp files if there is no need to do so. This prevents excessive hdd access. Though, there is one very minor issue - maybe you can help me: Since SysRemove(pszSSFileName); is always called it usually calls unlink() which returns in an strace an ENOENT (as the tmp file most of the time does not exist). I think that this issue is negligible. Still, Davide, can you please check whether we can simply remove that SysRemove() call as the tmp file should have never been created with my patch when iFileCount == 0? Thanks Stephan _______________________________________________ xmail mailing list [email protected] http://xmailserver.org/mailman/listinfo/xmail
500-LMAILSrv.patch
(text/x-patch, 1.2 KB)
--- LMAILSvr.cpp.orig 2010-05-26 08:49:02.000000000 +0200
+++ LMAILSvr.cpp 2010-05-26 08:49:58.000000000 +0200
@@ -116,6 +116,7 @@
int iMaxSSFileName)
{
char szSpoolDir[SYS_MAX_PATH];
+ FILE *pSSFile = NULL;
LMAILGetSpoolDir(szSpoolDir, sizeof(szSpoolDir));
@@ -129,14 +130,6 @@
UsrGetTmpFile(NULL, pszSSFileName, iMaxSSFileName);
- FILE *pSSFile = fopen(pszSSFileName, "wb");
-
- if (pSSFile == NULL) {
- ErrorPush();
- RLckUnlockSH(hResLock);
- return ErrorPop();
- }
-
int iFileCount = 0;
char szSpoolFileName[SYS_MAX_PATH];
FSCAN_HANDLE hFileScan = MscFirstFile(szSpoolDir, 0, szSpoolFileName,
@@ -149,13 +142,25 @@
if ((ulHashValue % (unsigned long) pLMAILCfg->lNumThreads) ==
(unsigned long) lThreadId) {
+ if(pSSFile == NULL) {
+ pSSFile = fopen(pszSSFileName, "wb");
+
+ if (pSSFile == NULL) {
+ ErrorPush();
+ RLckUnlockSH(hResLock);
+ return ErrorPop();
+ }
+ }
+
fprintf(pSSFile, "%s\r\n", szSpoolFileName);
++iFileCount;
}
} while (MscNextFile(hFileScan, szSpoolFileName, sizeof(szSpoolFileName)));
MscCloseFindFile(hFileScan);
}
- fclose(pSSFile);
+
+ if(pSSFile != NULL)
+ fclose(pSSFile);
RLckUnlockSH(hResLock);
if (iFileCount == 0) {