I have written a policy program and it works about 99% of the time. I have made numerous changes trying to isolate the problem so now I seek help from other users.
Background: Mercury/32 v4.62, Vista with all fixes and SP applied, VS2005 C++.
Program receives an ~A file and uses a specified Result file "policyresults.tmp" but no sentinel file. The specification of a Result file name is a partial fix to the problem which is more prevalent when allowing Mercury to create a temporary Result file. Following is the invocation command line.
F:\FILES\MERCURY\MAIL\emailspamdetector.exe ~A ~R F:\Files\Mercury\MAIL\whitelist.csv F:\Files\Mercury\MAIL\policy.log
First, a work around but not my current problem. The program only examines headers but I had to specify ~A instead of ~X in order to have the entire message attached to the Policy Exception message returned by Mercury when the policy program exits with other than a 0 return code. I didn't pick up on this when reading the documentation but my workaround is to stop processing headers when I encounter the first blank line and that works fine.
The problem is:
1. When I originally had Mercury returning a random named temporary file for the Result that file would sometimes be left in the SCRATCH folder instead of being deleted. That would happen at random times but about 2 or 3 times a day, usually when the computer was busy doing other background work like file transfers, backups, and such. However, it also would happen when the computer was idle.
2. I suspected a timing problem where Mercury was perhaps given an error when trying to delete the file and just ignored it leaving the file. I tried numerous techniques to try to see if it was timing problem. My PC is a low cost Gateway dual core with 1gb. I modified my program to have a 700 millisecond delay after closing all files prior to exit 0 or exit 1. The problem occurs with either kind of exit. The 700 millisecond delay before program exit did not seem to make any difference. I should point out that except for the .tmp file being orphaned the rest of the process works flawlessly.
3. I changed to a specified Result file and I have not seen it orphaned although if it is I assume it will be reused on a subsequent message. Thus, using the specified Result file seems to be a work around for the orphaned .tmp files and I'm fine with that.
4. The remaining problem is that the Result file will sometimes have none of the lines that I wrote to the file. In other words, Mercury gives the standard Policy Exception Notification email but no Result file contents. This happens about once every few days. I get about 10 - 20 policy exceptions per day out of a total email volume of about 50 - 100 messages per day.
What my program does is it reads the ~A file examining TO:, FROM:, and ENVELOPE-TO: headers in order to catch spam that has certain characteristics. For example, mail where the FROM: and the TO: are the same is, in my case, likely to be spam. I also check the FROM: as being in a white list whose file name is passed in the command line show above. I also append everything written to the Result file to a policy log file, also specified in the command line show above, so that I have a continuous history of all policy processing. I orginally did not have the policy log file but I added that when I was having the problem with orphaned .tmp files in the SCRATCH directory.
In summary, I suspect that the problem is Mercury being unable to access the Result file, either for purposes of adding the content to the Policy Exception message or for deleting the file. I have read that Mercury has been slowly adding multiple thread processing so perhaps this is related to that? Although I have been using Mercury for years the policy process is new and only used with 4.62.
Any thoughts are appreciated. I see that Mercury 5 is soon to be released and will include more thread processes. I hope to head off any problems with that.
Thanks.
<p>I have written a policy program and it works about 99% of the time.&nbsp; I have made numerous changes trying to isolate the problem so now I seek help from other users. </p><p>Background:&nbsp; Mercury/32 v4.62, Vista with all fixes and SP applied, VS2005 C++.</p><p>Program receives an ~A file and uses a specified Result file "policyresults.tmp" but no sentinel file.&nbsp; The specification of a Result file name is a partial fix to the problem which is more prevalent when allowing Mercury to create a temporary Result file. Following is the invocation command line.
</p><p>F:\FILES\MERCURY\MAIL\emailspamdetector.exe ~A ~R F:\Files\Mercury\MAIL\whitelist.csv F:\Files\Mercury\MAIL\policy.log </p><p>First, a work around but not my current problem.&nbsp; The program only examines headers but I had to specify ~A instead of ~X in order to have the entire message attached to the Policy Exception message returned by Mercury when the policy program exits with other than a 0 return code.&nbsp; I didn't pick up on this when reading the documentation but my workaround is to stop processing headers when I encounter the first blank line and that works fine.</p><p>The problem is:</p><p>1.&nbsp; When I originally had Mercury returning a random named temporary file for the Result that file would sometimes be left in the SCRATCH folder instead of being deleted.&nbsp; That would happen at random times but about 2 or 3 times a day, usually when the computer was busy doing other background work like file transfers, backups, and such.&nbsp; However, it also would happen when the computer was idle.</p><p>2.&nbsp; I suspected a timing problem where Mercury was perhaps given an error when trying to delete the file and just ignored it leaving the file.&nbsp; I tried numerous techniques to try to see if it was timing problem.&nbsp; My PC is a low cost Gateway dual core with 1gb.&nbsp; I modified my program to have a 700 millisecond delay after closing all files prior to exit 0 or exit 1.&nbsp; The problem occurs with either kind of exit.&nbsp; The 700 millisecond delay before program exit did not seem to make any difference. I should point out that except for the .tmp file being orphaned the rest of the process works flawlessly.</p><p>3.&nbsp; I changed to a specified Result file and I have not seen it orphaned although if it is I assume it will be reused on a subsequent message.&nbsp; Thus, using the specified Result file seems to be a work around for the orphaned .tmp files and I'm fine with that.</p><p>4.&nbsp; The remaining problem is that the Result file will sometimes have none of the lines that I wrote to the file.&nbsp; In other words, Mercury gives the standard Policy Exception Notification email but no Result file contents.&nbsp; This happens about once every few days.&nbsp; I get about 10 - 20 policy exceptions per day out of a total email volume of about 50 - 100 messages per day.</p><p>What my program does is it reads the ~A file examining TO:, FROM:, and ENVELOPE-TO: headers in order to catch spam that has certain characteristics.&nbsp; For example, mail where the FROM: and the TO: are the same is, in my case, likely to be spam.&nbsp; I also check the FROM: as being in a white list whose file name is passed in the command line show above.&nbsp; I also append everything written to the Result file to a policy log file, also specified in the command line show above, so that I have a continuous history of all policy processing.&nbsp; I orginally did not have the policy log file but I added that when I was having the problem with orphaned .tmp files in the SCRATCH directory. &nbsp;</p><p>&nbsp;In summary, I suspect that the problem is Mercury being unable to access the Result file, either for purposes of adding the content to the Policy Exception message or for deleting the file.&nbsp; I have read that Mercury has been slowly adding multiple thread processing so perhaps this is related to that?&nbsp; Although I have been using Mercury for years the policy process is new and only used with 4.62. &nbsp;</p><p>Any thoughts are appreciated.&nbsp; I see that Mercury 5 is soon to be released and will include more thread processes.&nbsp; I hope to head off any problems with that.</p><p>&nbsp;Thanks.
</p><p>&nbsp;</p><p>&nbsp;</p>