VirtualBox

Ignore:
Timestamp:
Jul 21, 2010 1:07:34 PM (15 years ago)
Author:
vboxsync
Message:

VBoxService: Review comments for Andy. Changed -pagefusionfork to --pagefusionfork and removed the negative comments as this is the best approach and we use it in several other places as well (VBoxSVC comes to mind). Some nits.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp

    r30758 r30957  
    496496int main(int argc, char **argv)
    497497{
    498     int rc = VINF_SUCCESS;
    499498    /*
    500499     * Init globals and such.
     
    503502
    504503    /*
    505      * Connect to the kernel part before daemonizing so we can fail
    506      * and complain if there is some kind of problem. We need to initialize
    507      * the guest lib *before* we do the pre-init just in case one of services
    508      * needs do to some initial stuff with it.
     504     * Connect to the kernel part before daemonizing so we can fail and
     505     * complain if there is some kind of problem.  We need to initialize the
     506     * guest lib *before* we do the pre-init just in case one of services needs
     507     * do to some initial stuff with it.
    509508     */
    510509    VBoxServiceVerbose(2, "Calling VbgR3Init()\n");
    511     rc = VbglR3Init();
     510    int rc = VbglR3Init();
    512511    if (RT_FAILURE(rc))
    513512        return VBoxServiceError("VbglR3Init failed with rc=%Rrc.\n", rc);
    514513
    515514#ifdef RT_OS_WINDOWS
    516     /* Special forked VBoxService.exe process for handling page fusion. */
    517     /* Note: ugly hack, but annoying to install additional executables. */
     515    /*
     516     * Check if we're the specially spawned VBoxService.exe process that
     517     * handles page fusion.  This saves an extra executable.
     518     */
    518519    if (    argc == 2
    519         &&  !strcmp(argv[1], "-pagefusionfork"))
    520     {
     520        &&  !strcmp(argv[1], "--pagefusionfork"))
    521521        return VBoxServicePageSharingInitFork();
    522     }
    523 #endif
    524 
    525     /* Do pre-init of services. */
     522#endif
     523
     524    /*
     525     * Do pre-init of services.
     526     */
    526527    g_pszProgName = RTPathFilename(argv[0]);
    527528    for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
     
    533534
    534535#ifdef RT_OS_WINDOWS
    535     /* Make sure only one instance of VBoxService runs at a time. Create a global mutex for that.
    536        Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */
    537     HANDLE hMutexAppRunning = CreateMutex (NULL, FALSE, VBOXSERVICE_NAME);
     536    /*
     537     * Make sure only one instance of VBoxService runs at a time.  Create a
     538     * global mutex for that.  Do not use a global namespace ("Global\\") for
     539     * mutex name here, will blow up NT4 compatibility!
     540     */
     541    /** @todo r=bird: Use Global\\ prefix or this serves no purpose on terminal servers. */
     542    HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, VBOXSERVICE_NAME);
    538543    if (   hMutexAppRunning != NULL
    539544        && GetLastError() == ERROR_ALREADY_EXISTS)
     
    544549        CloseHandle(hMutexAppRunning);
    545550        hMutexAppRunning = NULL;
     551
     552        /** @todo r=bird: How does this cause us to terminate?  Btw. Why do
     553         *        we do this before parsing parameters?  'VBoxService --help'
     554         *        and 'VBoxService --version' won't work now when the service
     555         *        is running... */
    546556    }
    547557#endif
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServicePageSharing.cpp

    r30755 r30957  
    681681        VBoxServiceVerbose(3, "VBoxServicePageSharingWorkerProcess: enabled=%d\n", fEnabled);
    682682
     683        /*
     684         * Start a 2nd VBoxService process to deal with page fusion as we do
     685         * not wish to dummy load dlls into this process.  (First load with
     686         * DONT_RESOLVE_DLL_REFERENCES, 2nd normal -> dll init routines not called!)
     687         */
    683688        if (    fEnabled
    684689            &&  hProcess == NIL_RTPROCESS)
    685690        {
    686691            char szExeName[256];
    687             char *pszExeName;
    688             char *pszArgs[3];
    689 
    690             pszExeName = RTProcGetExecutableName(szExeName, sizeof(szExeName));
    691 
     692            char *pszExeName = RTProcGetExecutableName(szExeName, sizeof(szExeName));
    692693            if (pszExeName)
    693694            {
     695                char const *papszArgs[3];
    694696                pszArgs[0] = pszExeName;
    695                 pszArgs[1] = "-pagefusionfork";
     697                pszArgs[1] = "--pagefusionfork";
    696698                pszArgs[2] = NULL;
    697                 /* Start a 2nd VBoxService process to deal with page fusion as we do not wish to dummy load
    698                  * dlls into this process. (first load with DONT_RESOLVE_DLL_REFERENCES, 2nd normal -> dll init routines not called!)
    699                  */
    700                 rc = RTProcCreate(pszExeName, pszArgs, RTENV_DEFAULT, 0 /* normal child */, &hProcess);
    701                 if (rc != VINF_SUCCESS)
     699                rc = RTProcCreate(pszExeName, papszArgs, RTENV_DEFAULT, 0 /* normal child */, &hProcess);
     700                if (RT_FAILURE(rc))
    702701                    VBoxServiceError("RTProcCreate %s failed; rc=%Rrc\n", pszExeName, rc);
    703702            }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette