Archived Forum Post

Index of archived forum posts

Question:

Mailman2 sendQ method and LastSendQFilename

Feb 20 '13 at 16:53

Using ChilkatMailMan2 sendQ method, an eml file gets created but the name of that file can only be found using a follow up step to retrieve the LastSendQFilename property. I am wondering if that property can be overwritten or changed by other concurrent mailman2 processes.

In my vb6 program, using mailman2 ActiveX, sendQ first creates the eml file in a local temp folder and then do a MoveFile to create a better named file in the actual local outgoing folder. One of my users who runs multiple email processes concurrently is experiencing sporadic failures to move the temp eml file (error 53: File not found).

Is it possible for another mailman instance running at the same time to interfere with the process so that LastSendQFilename returned by process A is actually the LastSendQFilename from process B?

Are there any other known issues that could cause the file name returned by LastSendQFilename to not be found even though sendQ reports success?

Thanks, - Ido


Answer

If two processes create an email at the exact same millisecond, AND it is the same Nth email for each process (for example, it is the 3rd email created for process A, and also the 3rd email created for process B), then there is a 1 in 4 billion chance that the random number generator would produce the same random number and there would be a collision of filenames.


Answer

The filename generated by the SendQ method has this format:

    sprintf(fname,"e_%04d%02d%02d_%02d%02d%02d_%06x%03x.eml",
       m_date.wYear,m_date.wMonth,m_date.wDay,m_date.wHour,
       m_date.wMinute,m_date.wSecond,currentTickCount,GenFnameIdx++);
The filename contains the current date/time, the current system's tick count which is the number of milliseconds that have elapsed since the system was started, as well as an ever-increasing counter value for the current process (which starts at 0). A collision would occur if two separate processes generate their Nth file at the same exact millisecond. (For example, each process generates its 4th file at the same exact millisecond.)


Answer

That may well explain these sporadic failures this user is seeing. Could you please add a new method or an overloaded argument that causes the name of the eml file to be always unique. For example, use a GUID.


Answer

Could you please confirm that 2 mailman processes running on the same machine would not share anything. 1) they don't share the GenFnameIdx 2) they don't share LastSendQFilename


Answer

Thanks but could you please also let me know if 2 mailman processes running on the same machine might share 1) the GenFnameIdx 2) the LastSendQFilename

Or are these methods/properties totally isolated from other mailman2 instances on the same machine?


Answer

Just to confirm, the new component genarets this file name: e_20130218_193135_cf701e000C9A3B624.eml


Answer

could you please let me know if 2 mailman processes running on the same machine might share 1) the GenFnameIdx 2) the LastSendQFilename

Or are these methods/properties totally isolated from other mailman2 instances on the same machine?


Answer

I understand the answers you provided earlier as well as this last answer. But I'm also asking a different question. I'm asking if 2 instances of mailman2 might SHARE any properties or are they totally isolated from each other?


Answer

Instead of including a random number for SendQ (with all the other extra timestamp numbers to make the filename unique), can't you just include the process id (http://msdn.microsoft.com/en-us/library/windows/desktop/ms683215%28v=vs.85%29.aspx) or thread id to make a unique filename?