Changeset 31597 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 12, 2010 12:49:46 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/webservice/vboxweb.cpp
r31539 r31597 29 29 30 30 #include <iprt/buildconfig.h> 31 #include <iprt/ctype.h> 32 #include <iprt/getopt.h> 33 #include <iprt/initterm.h> 34 #include <iprt/ldr.h> 35 #include <iprt/message.h> 36 #include <iprt/process.h> 37 #include <iprt/rand.h> 38 #include <iprt/semaphore.h> 39 #include <iprt/string.h> 31 40 #include <iprt/thread.h> 32 #include <iprt/rand.h>33 #include <iprt/initterm.h>34 #include <iprt/getopt.h>35 #include <iprt/ctype.h>36 #include <iprt/process.h>37 #include <iprt/string.h>38 #include <iprt/ldr.h>39 #include <iprt/semaphore.h>40 41 #include <iprt/time.h> 41 42 … … 104 105 105 106 bool g_fVerbose = false; // be verbose 106 PRTSTREAM g_p strLog = NULL;107 PRTSTREAM g_pStrmLog = NULL; 107 108 108 109 #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) … … 265 266 m_soap->max_keep_alive = g_cMaxKeepAlive; 266 267 267 if (!RT_SUCCESS(RTThreadCreate(&m_pThread, 268 fntWrapper, 269 this, // pvUser 270 0, // cbStack, 271 RTTHREADTYPE_MAIN_HEAVY_WORKER, 272 0, 273 m_strThread.c_str()))) 268 int rc = RTThreadCreate(&m_pThread, 269 fntWrapper, 270 this, // pvUser 271 0, // cbStack, 272 RTTHREADTYPE_MAIN_HEAVY_WORKER, 273 0, 274 m_strThread.c_str()); 275 if (RT_FAILURE(rc)) 274 276 { 275 RT StrmPrintf(g_pStdErr, "[!] Cannot start worker thread %d\n", u);277 RTMsgError("Cannot start worker thread %d: %Rrc\n", u, rc); 276 278 exit(1); 277 279 } … … 503 505 504 506 // log file 505 if (g_p strLog)506 { 507 RTStrmPrintf(g_p strLog, "%s %s", strPrefix.c_str(), psz);508 RTStrmFlush(g_p strLog);507 if (g_pStrmLog) 508 { 509 RTStrmPrintf(g_pStrmLog, "%s %s", strPrefix.c_str(), psz); 510 RTStrmFlush(g_pStrmLog); 509 511 } 510 512 … … 619 621 int main(int argc, char* argv[]) 620 622 { 621 int rc;622 623 623 // intialize runtime 624 RTR3Init(); 624 int rc = RTR3Init(); 625 if (RT_FAILURE(rc)) 626 return RTMsgInitFailure(rc); 625 627 626 628 // store a log prefix for this thread … … 657 659 case 'F': 658 660 { 659 int rc2 = RTStrmOpen(ValueUnion.psz, "a", &g_p strLog);661 int rc2 = RTStrmOpen(ValueUnion.psz, "a", &g_pStrmLog); 660 662 if (rc2) 661 { 662 RTPrintf("Error: Cannot open log file \"%s\" for writing, error %d.\n", ValueUnion.psz, rc2); 663 exit(2); 664 } 663 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Cannot open log file \"%s\" for writing: %Rrc", ValueUnion.psz, rc2); 665 664 666 665 WebLog("Sun VirtualBox Webservice Version %s\n" … … 705 704 rc = RTProcDaemonizeUsingFork(false /* fNoChDir */, false /* fNoClose */, NULL); 706 705 if (RT_FAILURE(rc)) 707 { 708 RTStrmPrintf(g_pStdErr, "vboxwebsrv: failed to daemonize, rc=%Rrc. exiting.\n", rc); 709 exit(1); 710 } 706 return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to daemonize, rc=%Rrc. exiting.", rc); 711 707 } 712 708 #endif 713 709 714 710 // intialize COM/XPCOM 715 rc = com::Initialize(); 716 if (FAILED(rc)) 717 { 718 RTPrintf("ERROR: failed to initialize COM!\n"); 719 return rc; 720 } 711 HRESULT hrc = com::Initialize(); 712 if (FAILED(hrc)) 713 return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to initialize COM! hrc=%Rhrc\n", hrc); 721 714 722 715 ComPtr<ISession> session; 723 716 724 rc = g_pVirtualBox.createLocalObject(CLSID_VirtualBox);725 if (FAILED( rc))726 RT Printf("ERROR: failed to create the VirtualBox object!\n");717 hrc = g_pVirtualBox.createLocalObject(CLSID_VirtualBox); 718 if (FAILED(hrc)) 719 RTMsgError("failed to create the VirtualBox object!"); 727 720 else 728 721 { 729 rc = session.createInprocObject(CLSID_Session);730 if (FAILED( rc))731 RT Printf("ERROR: failed to create a session object!\n");732 } 733 734 if (FAILED( rc))722 hrc = session.createInprocObject(CLSID_Session); 723 if (FAILED(hrc)) 724 RTMsgError("failed to create a session object!"); 725 } 726 727 if (FAILED(hrc)) 735 728 { 736 729 com::ErrorInfo info; 737 730 if (!info.isFullAvailable() && !info.isBasicAvailable()) 738 731 { 739 com::GluePrintRCMessage( rc);740 RT Printf("Most likely, the VirtualBox COM server is not running or failed to start.\n");732 com::GluePrintRCMessage(hrc); 733 RTMsgError("Most likely, the VirtualBox COM server is not running or failed to start."); 741 734 } 742 735 else 743 736 com::GluePrintErrorInfo(info); 744 return rc;737 return RTEXITCODE_FAILURE; 745 738 } 746 739 … … 752 745 753 746 // SOAP queue pumper thread 754 RTTHREAD tQPumper; 755 if (RTThreadCreate(&tQPumper, 756 fntQPumper, 757 NULL, // pvUser 758 0, // cbStack (default) 759 RTTHREADTYPE_MAIN_WORKER, 760 0, // flags 761 "SoapQPumper")) 762 { 763 RTStrmPrintf(g_pStdErr, "[!] Cannot start SOAP queue pumper thread\n"); 764 exit(1); 765 } 747 rc = RTThreadCreate(NULL, 748 fntQPumper, 749 NULL, // pvUser 750 0, // cbStack (default) 751 RTTHREADTYPE_MAIN_WORKER, 752 0, // flags 753 "SoapQPumper"); 754 if (RT_FAILURE(rc)) 755 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Cannot start SOAP queue pumper thread: %Rrc", rc); 766 756 767 757 // watchdog thread … … 769 759 { 770 760 // start our watchdog thread 771 RTTHREAD tWatchdog; 772 if (RTThreadCreate(&tWatchdog, 773 fntWatchdog, 774 NULL, 775 0, 776 RTTHREADTYPE_MAIN_WORKER, 777 0, 778 "Watchdog")) 779 { 780 RTStrmPrintf(g_pStdErr, "[!] Cannot start watchdog thread\n"); 781 exit(1); 782 } 761 rc = RTThreadCreate(NULL, 762 fntWatchdog, 763 NULL, 764 0, 765 RTTHREADTYPE_MAIN_WORKER, 766 0, 767 "Watchdog"); 768 if (RT_FAILURE(rc)) 769 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Cannot start watchdog thread: %Rrc", rc); 783 770 } 784 771 … … 790 777 int vrc = pQ->processEventQueue(RT_INDEFINITE_WAIT); 791 778 if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT) 792 com::GluePrintRCMessage(vrc);779 RTMsgError("processEventQueue -> %Rrc", rc); 793 780 } 794 781
Note:
See TracChangeset
for help on using the changeset viewer.