Initializing extensions

Hi there.

disclaimer: I’m a total newbie to Domino

I’m writing an extension for domino on linux/i386 (actually running the server on Gentoo linux), and I’m sorta confused about the proper way to initialize extensions. The MainEntryPoint function is called for every server process that starts, and I can’t put my finger on how to properly stop that from happening or if I should even care about it…

In the sample code I’ve looked at (extmngr.c, extpwd.c & extconf.c) the programs either do nothing of the sort, or use a global variable to mark if the module is initialized or not. The latter approach doesn’t really work since any global variable seems to be local to the process being started, which means that it still get’s initialized in that process. Using a static variable in the MainEntryPoint doesn’t work either (I’m logging around 24 init’s).

So I guess the question is: Since the only thing I’m doing in the init function is registering the callback function, does it matter if I do that many times? If it does matter, how do I avoid doing that multiple times?

Sample code that doesn’t work:

BOOL gInitialized = FALSE;

STATUS LNPUBLIC MainEntryPoint()

{

    static BOOL initialized = FALSE;

    STATUS state = NOERROR;



    if( TRUE == initialized )

            return(state);

    if( TRUE == gInitialized )

            return(state);

    initialized = gInitialized = TRUE;

    /*

     register callbacks etc.

    */

    return(state); 

}