VirtualBox

Changeset 24830 in vbox for trunk/src/VBox/Main/xpcom


Ignore:
Timestamp:
Nov 20, 2009 3:05:10 PM (15 years ago)
Author:
vboxsync
Message:

xpcom/server.cpp: More cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xpcom/server.cpp

    r24828 r24830  
    4242#include <iprt/critsect.h>
    4343#include <iprt/getopt.h>
     44#include <iprt/message.h>
     45#include <iprt/stream.h>
    4446#include <iprt/path.h>
    4547#include <iprt/timer.h>
    4648
    47 #include <stdio.h>
    4849#include <signal.h>     // for the signal handler
    4950#include <stdlib.h>
     
    285286
    286287        LogFlowFunc(("VirtualBox object deleted.\n"));
    287         printf("Informational: VirtualBox object deleted.\n");
     288        RTPrintf("Informational: VirtualBox object deleted.\n");
    288289    }
    289290
     
    505506                sInstance->AddRef(); /* protect FinalConstruct() */
    506507                rv = sInstance->FinalConstruct();
    507                 printf("Informational: VirtualBox object created (rc=%08X).\n", rv);
     508                RTPrintf("Informational: VirtualBox object created (rc=%Rhrc).\n", rv);
    508509                if (NS_FAILED(rv))
    509510                {
     
    816817        if (pipe(daemon_pipe_fds) < 0)
    817818        {
    818             printf("ERROR: pipe() failed (errno = %d)\n", errno);
     819            RTMsgError("pipe() failed (errno = %d)", errno);
    819820            return 1;
    820821        }
     
    825826        if (childpid == -1)
    826827        {
    827             printf("ERROR: fork() failed (errno = %d)\n", errno);
     828            RTMsgError("fork() failed (errno = %d)", errno);
    828829            return 1;
    829830        }
     
    845846                    fSuccess = true;
    846847                else
    847                     printf("ERROR: Unknown message from child process (%s)\n", msg);
     848                    RTMsgError("Unknown message from child process (%s)", msg);
    848849            }
    849850            else
    850                 printf("ERROR: 0 bytes read from child process\n");
     851                RTMsgError("0 bytes read from child process");
    851852
    852853            /* close the reading end of the pipe as well and exit */
     
    860861        if (sid < 0)
    861862        {
    862             printf("ERROR: setsid() failed (errno = %d)\n", errno);
     863            RTMsgError("setsid() failed (errno = %d)", errno);
    863864            return 1;
    864865        }
     
    870871        if (childpid == -1)
    871872        {
    872             printf("ERROR: second fork() failed (errno = %d)\n", errno);
     873            RTMsgError("second fork() failed (errno = %d)", errno);
    873874            return 1;
    874875        }
     
    945946        if (NS_FAILED(rc))
    946947        {
    947             printf("ERROR: Failed to initialize XPCOM! (rc=%08X)\n", rc);
     948            RTMsgError("Failed to initialize XPCOM! (rc=%Rhrc)\n", rc);
    948949            break;
    949950        }
     
    953954        if (NS_FAILED(rc))
    954955        {
    955             printf("ERROR: Failed to get component registrar! (rc=%08X)\n", rc);
     956            RTMsgError("Failed to get component registrar! (rc=%Rhrc)", rc);
    956957            break;
    957958        }
     
    962963        if (NS_FAILED(rc))
    963964        {
    964             printf("ERROR: Failed to register server components! (rc=%08X)\n", rc);
     965            RTMsgError("Failed to register server components! (rc=%Rhrc)", rc);
    965966            break;
    966967        }
     
    972973        if (NS_FAILED(rc))
    973974        {
    974             printf("ERROR: Failed to get the main event queue! (rc=%08X)\n", rc);
     975            RTMsgError("Failed to get the main event queue! (rc=%Rhrc)", rc);
    975976            break;
    976977        }
     
    979980        if (NS_FAILED (rc))
    980981        {
    981             printf("ERROR: Failed to get IPC service! (rc=%08X)\n", rc);
     982            RTMsgError("Failed to get IPC service! (rc=%Rhrc)", rc);
    982983            break;
    983984        }
     
    993994                         "Is another server already running?\n", rc, rc));
    994995
    995             printf("ERROR: Failed to register the server name \"%s\" (rc=%08X)!\n"
    996                    "Is another server already running?\n",
    997                    VBOXSVC_IPC_NAME, rc);
     996            RTMsgError("Failed to register the server name \"%s\" (rc=%Rhrc)!\n"
     997                       "Is another server already running?\n",
     998                       VBOXSVC_IPC_NAME, rc);
    998999            NS_RELEASE(gIpcServ);
    9991000            break;
     
    10211022            for (int i = iSize; i > 0; i--)
    10221023                putchar('*');
    1023             printf("\n%s\n", szBuf);
    1024             printf("(C) 2008-2009 Sun Microsystems, Inc.\n"
    1025                    "All rights reserved.\n");
     1024            RTPrintf("\n%s\n", szBuf);
     1025            RTPrintf("(C) 2008-2009 Sun Microsystems, Inc.\n"
     1026                     "All rights reserved.\n");
    10261027#ifdef DEBUG
    1027             printf("Debug version.\n");
     1028            RTPrintf("Debug version.\n");
    10281029#endif
    10291030        }
     
    10311032        if (daemon_pipe_wr >= 0)
    10321033        {
    1033             printf("\nStarting event loop....\n[send TERM signal to quit]\n");
     1034            RTPrintf("\nStarting event loop....\n[send TERM signal to quit]\n");
    10341035            /* now we're ready, signal the parent process */
    10351036            write(daemon_pipe_wr, "READY", strlen("READY"));
    10361037        }
    10371038        else
    1038             printf("\nStarting event loop....\n[press Ctrl-C to quit]\n");
     1039            RTPrintf("\nStarting event loop....\n[press Ctrl-C to quit]\n");
    10391040
    10401041        if (g_pszPidFile)
    10411042        {
    1042             RTFILE pidFile = NIL_RTFILE;
    1043             vrc = RTFileOpen(&pidFile, g_pszPidFile, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE);
     1043            RTFILE hPidFile = NIL_RTFILE;
     1044            vrc = RTFileOpen(&hPidFile, g_pszPidFile, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE);
    10441045            if (RT_SUCCESS(vrc))
    10451046            {
     
    10471048                const char *lf = "\n";
    10481049                RTStrFormatNumber(szBuf, getpid(), 10, 0, 0, 0);
    1049                 RTFileWrite(pidFile, szBuf, strlen(szBuf), NULL);
    1050                 RTFileWrite(pidFile, lf, strlen(lf), NULL);
    1051                 RTFileClose(pidFile);
     1050                RTFileWrite(hPidFile, szBuf, strlen(szBuf), NULL);
     1051                RTFileWrite(hPidFile, lf, strlen(lf), NULL);
     1052                RTFileClose(hPidFile);
    10521053            }
    10531054        }
     
    10621063                lim.rlim_cur = RT_MIN(lim.rlim_max, 10240);
    10631064                if (setrlimit(RLIMIT_NOFILE, &lim) == -1)
    1064                     printf("WARNING: failed to increase file descriptor limit. (%d)\n", errno);
     1065                    RTPrintf("WARNING: failed to increase file descriptor limit. (%d)\n", errno);
    10651066            }
    10661067        }
    10671068        else
    1068             printf("WARNING: failed to obtain per-process file-descriptor limit (%d).\n", errno);
     1069            RTPrintf("WARNING: failed to obtain per-process file-descriptor limit (%d).\n", errno);
    10691070
    10701071        PLEvent *ev;
     
    10911092        gEventQ->ProcessPendingEvents();
    10921093
    1093         printf("Terminated event loop.\n");
     1094        RTPrintf("Terminated event loop.\n");
    10941095    }
    10951096    while (0); // this scopes the nsCOMPtrs
     
    11041105    LogFlowFunc(("Finished com::Shutdown() (rc=%Rhrc)\n", rc));
    11051106
    1106     if (NS_FAILED (rc))
    1107         printf("ERROR: Failed to shutdown XPCOM! (rc=%08X)\n", rc);
    1108 
    1109     printf("XPCOM server has shutdown.\n");
     1107    if (NS_FAILED(rc))
     1108        RTMsgError("Failed to shutdown XPCOM! (rc=%Rhrc)", rc);
     1109
     1110    RTPrintf("XPCOM server has shutdown.\n");
    11101111
    11111112    if (g_pszPidFile)
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