HiI have written the server add-in library with the extension manager registration. I’m registering EM_NSFNOTEUPDATE event handler. I’m logging every call of the MainEntryPoint function and I observe many calls at domino start (over 10-15). Additionally, if I start a new task („load some_task” on the domino console), I observe next call of MainEntryPoint function. Is this correct?
When should I unregister the handler? I worry about stability of my domino. I’m using domino 6.5.4 on linux. Compiler is gcc.
Subject: Extension Manager - many registrations
Yes this is correct. After you’ve registered your event you will receive notification of every single Note Update and then it’s up to you to handle.
Alex
Subject: RE: Extension Manager - many registrations
I’m receiving notifications from NSFNOTEUPDATE event and it’s right. But my handler is registered many times because function MainEntryPoint of my library is called many times. I think that every domino task calls MainEntryPoint function at start.
I think when I write “tell task quit” on domino console the EMDeregister function should be called. But I don’t know where I should place the call of this function.
Subject: RE: Extension Manager - many registrations
That’s correct. Each Domino task loads its own instance of your DLL. Generally not a big deal, but be careful if you are doing things like creating/deleting temp files – don’t assume that you can use a single pre-set filename.
-rich
Subject: RE: Extension Manager - many registrations
Is the EMDeregister necessary in this case?
Subject: RE: Extension Manager - many registrations
Either that, or avoid registering in the first place, except when you know that the task that loaded your DLL is the one that you need to be registered for.
Subject: Absolutely
Without the deregister, your application will likely terminate incorrectly.
Subject: Absolutely?
I repeat my question. My application is just shared object library which is loaded with each task start (declared in EXTMGR_ADDINS parameter of notes.ini). EMRegister is called in MainAntryPoint function. Where should I place the EMDeregister function call?
Subject: RE: Absolutely?
Initialization and termination
On Win2K/NT, the initialization and termination entry point for a DLL is the DllMain function. When each new process gains access to the DLL, this function initializes the necessary environment for the DLL. When each new process frees its access to the DLL, this function terminates the DLL for that environment. This function is called automatically when you link to the DLL. For applications, an additional initialization and termination routine is included in the DllMain function.
On Linux, the GCC has an extension that allows specifying that a function should be called when the executable or shared object containing it is started up or finished. The syntax is attribute((constructor)) or attribute((destructor)). These are basically the same as constructors and destructors to replace the _init and _fini functions from the glibc library.
Registering more than once is just silly so why don’t you figure out who you want to be doing it and act accordingly.
Subject: RE: Absolutely?
That is pretty interesting for GCC entrypoints. Do you know if there is something equivalent for AIX?
We have found that relying on DLLMain() for shtudown is, well, unreliable. My Extension Manager creates a singleton Domino background thread and if it is Domino-enabled then our DLLMain will never be called; instead we have a cobbled arrangement of constantly initializing/deinitializing the Domino thread infrastructure each time through the processing thread main loop such that Domino is not in use when the thread sleeps. In this case we can rely on the super-underdocumented EM_TERMINATENSF callback.
I’d love to have better documentation for platform-neutral EM lifetime management.
Regards,
Ken