- Timestamp:
- Mar 14, 2007 2:59:04 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 19531
- Location:
- trunk/src/VBox/Main
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile
r1349 r1471 38 38 $(error "VBox: VBOX_WITH_XPCOM isn't defined") 39 39 endif 40 DLLS = VBoxSVCM 40 41 LIBRARIES = VBoxXPCOM 41 42 DEFS += VBOX_WITH_XPCOM … … 94 95 95 96 # 96 # VBoxSVC 97 # VBoxSVC executable 97 98 # 98 99 VBoxSVC_TEMPLATE = VBOXMAINEXE … … 198 199 199 200 # 200 # VBoxC 201 # VBoxSVC wrapper module 202 # 203 ifdef VBOX_WITH_XPCOM 204 205 VBoxSVCM_TEMPLATE = VBOXMAIN 206 VBoxSVCM_DEFS = IN_RING3 IN_CFGLDR_R3 207 VBoxSVCM_INCS = \ 208 include \ 209 $(PATH_VBoxC) \ 210 $(PATH_VBoxCOM) 211 VBoxSVCM_SOURCES = \ 212 linux/server_module.cpp 213 214 endif # VBOX_WITH_XPCOM 215 216 # 217 # VBoxC module 201 218 # 202 219 VBoxC_TEMPLATE = VBOXMAIN … … 437 454 xpcom-components_SYMLINKS = \ 438 455 VBoxC$(SUFF_DLL)=>../VBoxC$(SUFF_DLL) \ 456 VBoxSVCM$(SUFF_DLL)=>../VBoxSVCM$(SUFF_DLL) \ 439 457 VBoxXPCOMIPCC$(SUFF_DLL)=>../VBoxXPCOMIPCC$(SUFF_DLL) \ 440 458 VirtualBox_XPCOM.xpt=>../VirtualBox_XPCOM.xpt \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r1218 r1471 64 64 name="VirtualBox" 65 65 uuid="46137EEC-703B-4fe5-AFD4-7C9BBBBA0259" 66 version="1. 0"67 desc="InnoTek VirtualBox MachineType Library"66 version="1.3" 67 desc="InnoTek VirtualBox Type Library" 68 68 supportsErrorInfo="yes" 69 69 > … … 1473 1473 </interface> 1474 1474 1475 <class name="VirtualBox" uuid="B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F"> 1475 <class name="VirtualBox" uuid="B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F" 1476 namespace="virtualbox.org"> 1476 1477 <interface name="IVirtualBox" default="yes"/> 1477 1478 </class> … … 7202 7203 </interface> 7203 7204 7204 <class name="Session" uuid="3C02F46D-C9D2-4f11-A384-53F0CF917214"> 7205 <class name="Session" uuid="3C02F46D-C9D2-4f11-A384-53F0CF917214" 7206 namespace="virtualbox.org"> 7205 7207 <interface name="ISession" default="yes"/> 7206 7208 </class> -
trunk/src/VBox/Main/idl/xpidl.xsl
r1142 r1471 291 291 <xsl:with-param name="str" select="@name"/> 292 292 </xsl:call-template> 293 <xsl:text>_CONTRACTID "@xpcom/</xsl:text><xsl:value-of select="@name"/> 294 <xsl:text>;1"
</xsl:text> 293 <!-- Contract ID --> 294 <xsl:text>_CONTRACTID "@</xsl:text> 295 <xsl:value-of select="@namespace"/> 296 <xsl:text>/</xsl:text> 297 <xsl:value-of select="@name"/> 298 <xsl:text>;1"
</xsl:text> 295 299 <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 --> 296 300 <xsl:text>// for compatibility with Win32
</xsl:text> -
trunk/src/VBox/Main/linux/module.cpp
r436 r1471 21 21 22 22 #include <nsIGenericFactory.h> 23 #include <VirtualBox_XPCOM.h>24 23 25 #include <GuestImpl.h> 26 #include <KeyboardImpl.h> 27 #include <MouseImpl.h> 28 #include <DisplayImpl.h> 29 #include <MachineDebuggerImpl.h> 30 #include <USBDeviceImpl.h> 31 #include <RemoteUSBDeviceImpl.h> 32 #include <SharedFolderImpl.h> 33 #include <FramebufferImpl.h> 34 #include <ProgressImpl.h> 35 #include <NetworkAdapterImpl.h> 24 // generated file 25 #include "VirtualBox_XPCOM.h" 36 26 37 #include <SessionImpl.h> 38 #include <ConsoleImpl.h> 39 #include <ConsoleVRDPServer.h> 27 #include "GuestImpl.h" 28 #include "KeyboardImpl.h" 29 #include "MouseImpl.h" 30 #include "DisplayImpl.h" 31 #include "MachineDebuggerImpl.h" 32 #include "USBDeviceImpl.h" 33 #include "RemoteUSBDeviceImpl.h" 34 #include "SharedFolderImpl.h" 35 #include "FramebufferImpl.h" 36 #include "ProgressImpl.h" 37 #include "NetworkAdapterImpl.h" 38 39 #include "SessionImpl.h" 40 #include "ConsoleImpl.h" 41 #include "ConsoleVRDPServer.h" 42 43 #include "Logging.h" 40 44 41 45 // XPCOM glue code unfolding … … 76 80 77 81 /** 78 * Singleton class factory that holds thereference to the created instance82 * Singleton class factory that holds a reference to the created instance 79 83 * (preventing it from being destroyed) until the module is explicitly 80 84 * unloaded by the XPCOM shutdown code. … … 129 133 NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC (Session) 130 134 135 136 /** 137 * Component definition table. 138 * Lists all components defined in this module. 139 */ 131 140 static const nsModuleComponentInfo components[] = 132 141 { 133 142 { 134 "Session component", NS_SESSION_CID, NS_SESSION_CONTRACTID, 135 SessionConstructor, 143 "Session component", // description 144 NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID 145 SessionConstructor, // constructor function 136 146 NULL, // registration function 137 147 NULL, // deregistration function … … 139 149 // SessionClassFactory::releaseInstance, 140 150 NULL, // destructor function 141 NS_CI_INTERFACE_GETTER_NAME(Session), 151 NS_CI_INTERFACE_GETTER_NAME(Session), // interfaces function 142 152 NULL, // language helper 143 &NS_CLASSINFO_NAME(Session) 153 &NS_CLASSINFO_NAME(Session) // global class info & flags 144 154 } 145 155 }; 146 156 147 NS_IMPL_NSGETMODULE (SessionModule, components)157 NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components) 148 158 -
trunk/src/VBox/Main/linux/server.cpp
r1397 r1471 1 1 /** @file 2 2 * 3 * XPCOM server module implementation3 * XPCOM server process start point 4 4 */ 5 5 … … 39 39 #include <iprt/path.h> 40 40 #include <iprt/critsect.h> 41 #include <iprt/timer.h> 42 41 43 #include <VBox/param.h> 42 44 #include <VBox/version.h> … … 187 189 //////////////////////////////////////////////////////////////////////////////// 188 190 191 enum 192 { 193 /* Delay before shutting down the VirtualBox server after the last 194 * VirtualBox instance is released, in ms */ 195 VBoxSVC_ShutdownDelay = 5000, 196 }; 197 198 static bool gAutoShutdown = false; 199 189 200 static nsIEventQueue* gEventQ = nsnull; 190 201 static PRBool volatile gKeepRunning = PR_TRUE; … … 203 214 virtual ~VirtualBoxClassFactory() 204 215 { 205 Log (("VirtualBoxClassFactory: deleting VirtualBox...\n"));216 LogFlowFunc (("Deleting VirtualBox...\n")); 206 217 207 218 FinalRelease(); 208 219 sInstance = 0; 209 220 210 Log (("VirtualBoxClassFactory:VirtualBox object deleted.\n"));221 LogFlowFunc (("VirtualBox object deleted.\n")); 211 222 printf ("Informational: VirtualBox object deleted.\n"); 223 224 /* Instruct the main event loop to terminate. Note that it's enough 225 * to set gKeepRunning to false because we are on the main thread 226 * already (i.e. no need to post events there). */ 227 if (gAutoShutdown) 228 gKeepRunning = PR_FALSE; 212 229 } 213 230 214 231 NS_IMETHOD_(nsrefcnt) Release() 215 232 { 216 / /we overload Release() to guarantee the VirtualBox destructor is217 // always called on the main thread233 /* we overload Release() to guarantee the VirtualBox destructor is 234 * always called on the main thread */ 218 235 219 236 nsrefcnt count = VirtualBox::Release(); … … 221 238 if (count == 1) 222 239 { 223 / /the last reference held by clients is being released224 // (see GetInstance())240 /* the last reference held by clients is being released 241 * (see GetInstance()) */ 225 242 226 243 PRBool onMainThread = PR_TRUE; … … 230 247 if (!onMainThread) 231 248 { 232 // post a destruction event to the main thread to release the 233 // extra reference added in GetInstance() 234 235 LogFlow (("VirtualBoxClassFactory: the last VirtualBox reference " 236 "is being released, scheduling the destruction...\n")); 237 238 PLEvent *ev = new PLEvent; 239 gEventQ->InitEvent (ev, NULL, DestructEventHandler, 240 DestructEventDestructor); 241 nsresult rv = gEventQ->PostEvent (ev); 242 if (NS_FAILED (rv)) 249 LogFlowFunc (("Last VirtualBox instance was released, " 250 "scheduling server shutdown in %d ms...\n", 251 VBoxSVC_ShutdownDelay)); 252 253 /* Start a shutdown timer to provide some delay */ 254 int vrc = RTTimerStart (sTimer, 0); 255 /// @todo uncomment when implemented 256 // AssertRC (vrc); 257 if (VBOX_FAILURE (vrc)) 243 258 { 244 // this means we've been already stopped (for example 245 // by Ctrl-C). FactoryDestructor() (NS_ShutdownXPCOM()) 246 // will do the job. 247 PL_DestroyEvent (ev); 259 /* failed to start the timer, post the shutdown event 260 * manually */ 261 ShutdownTimer (NULL, NULL); 248 262 } 249 263 } 250 264 else 251 265 { 252 // Here we come if: 253 // 254 // a) gEventQ is 0 which means either FactoryDestructor() is called 255 // or the IPC/DCONNECT shutdown sequence is initiated by the 256 // XPCOM shutdown routine (NS_ShutdownXPCOM()), which always 257 // happens on the main thread. 258 // 259 // b) gEventQ has reported we're on the main thread. This means 260 // that DestructEventHandler() has been called, but another 261 // client was faster and requested VirtualBox again. 262 // 263 // We have nothing to do in these cases. 266 /* Here we come if: 267 * 268 * a) gEventQ is 0 which means either FactoryDestructor() is called 269 * or the IPC/DCONNECT shutdown sequence is initiated by the 270 * XPCOM shutdown routine (NS_ShutdownXPCOM()), which always 271 * happens on the main thread. 272 * 273 * b) gEventQ has reported we're on the main thread. This means 274 * that DestructEventHandler() has been called, but another 275 * client was faster and requested VirtualBox again. 276 * 277 * We have nothing to do in these cases. 278 */ 264 279 } 265 280 } … … 272 287 Assert (RTCritSectIsInitialized (&sLock)); 273 288 274 / / stop accepting GetInstance() requests during possible destruction289 /* stop accepting GetInstance() requests during possible destruction */ 275 290 RTCritSectEnter (&sLock); 276 291 277 292 Assert (sInstance); 278 293 279 / /release the reference we added in GetInstance()280 // (will call the destructor if nobody referenced us again)294 /* release the reference we added in GetInstance() 295 * (will call the destructor if nobody referenced us again) */ 281 296 nsrefcnt count = sInstance->Release(); 282 297 if (count != 0) 283 298 { 284 LogFlow (("VirtualBoxClassFactory: destruciton is canceled\n"));299 LogFlowFunc (("Destruction is canceled.\n")); 285 300 } 286 301 … … 295 310 } 296 311 312 static void ShutdownTimer (PRTTIMER pTimer, void *pvUser) 313 { 314 NOREF (pvUser); 315 316 if (pTimer) 317 { 318 /* it's a single shot timer */ 319 int vrc = RTTimerStop (pTimer); 320 /// @todo uncomment when implemented 321 // AssertRC (vrc); 322 NOREF (vrc); 323 } 324 325 /* post a destruction event to the main thread to safely release the 326 * extra reference added in VirtualBoxClassFactory::GetInstance() */ 327 328 LogFlowFunc (("Posting VirtualBox destruction & shtutdown event...\n")); 329 330 PLEvent *ev = new PLEvent; 331 gEventQ->InitEvent (ev, NULL, DestructEventHandler, 332 DestructEventDestructor); 333 nsresult rv = gEventQ->PostEvent (ev); 334 if (NS_FAILED (rv)) 335 { 336 /* this means we've been already stopped (for example 337 * by Ctrl-C). FactoryDestructor() (NS_ShutdownXPCOM()) 338 * will do the job. */ 339 PL_DestroyEvent (ev); 340 } 341 } 342 297 343 static NS_IMETHODIMP FactoryConstructor() 298 344 { 299 LogFlow (("VirtualBoxClassFactory::FactoryConstructor()\n"));300 301 / / create a critsect to protect object construction345 LogFlowFunc (("\n")); 346 347 /* create a critsect to protect object construction */ 302 348 if (VBOX_FAILURE (RTCritSectInit (&sLock))) 303 349 return NS_ERROR_OUT_OF_MEMORY; 304 350 351 int vrc = RTTimerCreateEx (&sTimer, 352 uint64_t (VBoxSVC_ShutdownDelay) * 1000000, 353 0, ShutdownTimer, NULL); 354 NOREF (vrc); 355 /// @todo uncomment when implemented 356 // if (VBOX_FAILURE (vrc)) 357 // { 358 // LogFlowFunc (("Failed to create a timer! (vrc=%Vrc)\n", vrc)); 359 // return NS_ERROR_FAILURE; 360 // } 361 305 362 return NS_OK; 306 363 } … … 308 365 static NS_IMETHODIMP FactoryDestructor() 309 366 { 310 LogFlow (("VirtualBoxClassFactory::FactoryDestructor()\n")); 367 LogFlowFunc (("\n")); 368 369 RTTimerDestroy (sTimer); 370 sTimer = NULL; 311 371 312 372 RTCritSectDelete (&sLock); … … 314 374 if (sInstance) 315 375 { 316 / /Either posting a destruction event falied for some reason (most317 //likely, the quit event has been received before the last release),318 //or the client has terminated abnormally w/o releasing its319 //VirtualBox instance (so NS_ShutdownXPCOM() is doing a cleanup).320 // Release the extra reference we added in GetInstance().376 /* Either posting a destruction event falied for some reason (most 377 * likely, the quit event has been received before the last release), 378 * or the client has terminated abnormally w/o releasing its 379 * VirtualBox instance (so NS_ShutdownXPCOM() is doing a cleanup). 380 * Release the extra reference we added in GetInstance(). */ 321 381 sInstance->Release(); 322 382 } … … 327 387 static nsresult GetInstance (VirtualBox **inst) 328 388 { 329 Log (("VirtualBoxClassFactory: getting VirtualBox object...\n"));389 LogFlowFunc (("Getting VirtualBox object...\n")); 330 390 331 391 RTCritSectEnter (&sLock); … … 335 395 if (sInstance == 0) 336 396 { 337 Log (("VirtualBoxClassFactory: creating new VirtualBox object...\n"));397 LogFlowFunc (("Creating new VirtualBox object...\n")); 338 398 sInstance = new VirtualBoxClassFactory(); 339 399 if (sInstance) 340 400 { 341 / /make an extra AddRef to take the full control342 // on the VirtualBox destruction (see FinalRelease())401 /* make an extra AddRef to take the full control 402 * on the VirtualBox destruction (see FinalRelease()) */ 343 403 sInstance->AddRef(); 344 404 345 sInstance->AddRef(); / / protect FinalConstruct()405 sInstance->AddRef(); /* protect FinalConstruct() */ 346 406 rv = sInstance->FinalConstruct(); 347 407 printf ("Informational: VirtualBox object created (rc=%08X).\n", rv); 348 408 if (NS_FAILED (rv)) 349 409 { 350 // on failure diring VirtualBox initialization, delete it 351 // immediately on the current thread, ignoring the reference 352 // count (VirtualBox should be aware of that meaning that it 353 // has already completely unintialized itself in this case) 354 Log (("VirtualBoxClassFactory: VirtualBox creation failed " 355 "(rc=%08X), deleting immediately...\n", rv)); 410 /* on failure diring VirtualBox initialization, delete it 411 * immediately on the current thread, ignoring the reference 412 * count (VirtualBox should be aware of that meaning that it 413 * has already completely unintialized itself in this 414 * case) */ 415 LogFlowFunc (("VirtualBox creation failed " 416 "(rc=%08X), deleting immediately...\n", rv)); 356 417 delete sInstance; 357 418 sInstance = 0; … … 365 426 else 366 427 { 367 Log (("VirtualBoxClassFactory: using existing VirtualBox object...\n"));428 LogFlowFunc (("Using existing VirtualBox object...\n")); 368 429 nsrefcnt count = sInstance->AddRef(); 369 430 Assert (count > 1); … … 371 432 if (count == 2) 372 433 { 373 LogFlow (("VirtualBoxClassFactory: another client has requested "374 "a reference of VirtualBox scheduled for destruction, "375 "canceling detruction...\n"));376 377 / /add a reference to compensate one that DestructEventHandler()378 // will release434 LogFlowFunc (("Another client has requested " 435 "a reference of VirtualBox scheduled for destruction, " 436 "canceling detruction...\n")); 437 438 /* add a reference to compensate one that DestructEventHandler() 439 * will release */ 379 440 sInstance->AddRef(); 380 441 } … … 392 453 static VirtualBox *sInstance; 393 454 static RTCRITSECT sLock; 455 456 static PRTTIMER sTimer; 394 457 }; 395 458 … … 397 460 RTCRITSECT VirtualBoxClassFactory::sLock = {0}; 398 461 399 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC ( 400 VirtualBox, VirtualBoxClassFactory::GetInstance 401 ) 462 PRTTIMER VirtualBoxClassFactory::sTimer = NULL; 463 464 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC 465 (VirtualBox, VirtualBoxClassFactory::GetInstance) 402 466 403 467 //////////////////////////////////////////////////////////////////////////////// … … 477 541 * starts up (somewhere during the initialization of the libipcdc.so module) 478 542 * when we just reference XPCOM's NS_NewGenericFactory() from here (i.e. even 479 * before actually calling it) and run VBoxSVC using the debug XPCOM libraries. 543 * before actually calling it) and run VBoxSVC using the debug XPCOM 544 * libraries. 545 * 546 * Actually, I know why, but I find it too stupid even to discuss. 480 547 */ 481 548 class nsMyFactory : public nsIGenericFactory, public nsIClassInfo { … … 677 744 ///////////////////////////////////////////////////////////////////////////// 678 745 679 // a helper function to register self components upon start-up 680 // of the out-of-proc server 681 static nsresult RegisterSelfComponents ( 682 nsIComponentRegistrar *registrar, 683 const nsMyModuleComponentInfo *components, PRUint32 count) 746 /** 747 * Hhelper function to register self components upon start-up 748 * of the out-of-proc server. 749 */ 750 static nsresult 751 RegisterSelfComponents (nsIComponentRegistrar *registrar, 752 const nsMyModuleComponentInfo *components, 753 PRUint32 count) 684 754 { 685 755 nsresult rc = NS_OK; 686 756 const nsMyModuleComponentInfo *info = components; 687 for (PRUint32 i = 0; i < count && NS_SUCCEEDED( rc ); i++, info++) { 688 // skip components w/o a constructor 757 for (PRUint32 i = 0; i < count && NS_SUCCEEDED (rc); i++, info++) 758 { 759 /* skip components w/o a constructor */ 689 760 if (!info->mConstructor) continue; 690 / / create a new generic factory for a component and register it761 /* create a new generic factory for a component and register it */ 691 762 nsIGenericFactory *factory; 692 //rc = NS_NewGenericFactory (&factory, info);763 rc = NS_NewGenericFactory (&factory, info); 693 764 rc = NS_NewMyFactory (&factory, info); 694 if (NS_SUCCEEDED( rc )) { 695 rc = registrar->RegisterFactory ( 696 info->mCID, 697 info->mDescription, 698 info->mContractID, 699 factory 700 ); 765 if (NS_SUCCEEDED (rc)) 766 { 767 rc = registrar->RegisterFactory (info->mCID, 768 info->mDescription, 769 info->mContractID, 770 factory); 701 771 factory->Release(); 702 772 } … … 706 776 707 777 ///////////////////////////////////////////////////////////////////////////// 708 709 #define VIRTUALBOXSERVER_IPCNAME "VirtualBoxServer"710 778 711 779 static ipcIService *gIpcServ = nsnull; … … 715 783 void PR_CALLBACK quitEventDestructor (PLEvent* self) { delete self; } 716 784 717 void signal_handler (int sig)785 static void signal_handler (int sig) 718 786 { 719 787 if (gEventQ && gKeepRunning) 720 788 { 721 / / post a quit event to the queue789 /* post a quit event to the queue */ 722 790 PLEvent *ev = new PLEvent; 723 791 gEventQ->InitEvent (ev, NULL, quitEventHandler, quitEventDestructor); … … 735 803 * the code is taken from http://www.linuxjournal.com/article/6391. 736 804 */ 737 void bt_sighandler (int sig, siginfo_t *info, void *secret)805 static void bt_sighandler (int sig, siginfo_t *info, void *secret) 738 806 { 739 807 … … 768 836 const struct option options[] = 769 837 { 838 { "automate", no_argument, NULL, 'a' }, 770 839 { "daemonize", no_argument, NULL, 'd' }, 771 840 { "pidfile", required_argument, NULL, 'p' }, … … 783 852 switch (c) 784 853 { 854 case 'a': 855 { 856 /* --automate mode means we are started by XPCOM on 857 * demand. Daemonize ourselves and activate 858 * auto-shutdown. */ 859 gAutoShutdown = true; 860 fDaemonize = true; 861 break; 862 } 863 785 864 case 'd': 786 865 { … … 796 875 797 876 default: 798 break; 877 { 878 /* exit on invalid options */ 879 return 1; 880 } 799 881 } 800 882 } … … 808 890 if (pipe(daemon_pipe_fds) < 0) 809 891 { 810 printf("E rror creating pipe! errno = %d\n", errno);892 printf("ERROR: pipe() failed (errno = %d)\n", errno); 811 893 return 1; 812 894 } … … 815 897 if (childpid == -1) 816 898 { 817 printf("E rror failed to fork!\n");899 printf("ERROR: fork() failed (errno = %d)\n", errno); 818 900 return 1; 819 901 } … … 832 914 { 833 915 if (strcmp(msg, "READY") == 0) 834 {835 Log (("child process signalled ready\n"));836 916 fSuccess = true; 837 }838 917 else 839 { 840 Log (("unknown message from child\n")); 841 } 918 printf ("ERROR: Unknown message from child " 919 "process (%s)\n", msg); 842 920 } 843 921 else 844 { 845 Log (("0 bytes read from child process\n")); 846 } 922 printf ("ERROR: 0 bytes read from child process\n"); 923 847 924 /* close the reading end of the pipe as well and exit */ 848 925 close(daemon_pipe_fds[0]); … … 851 928 /* we're the child process */ 852 929 930 /* Create a new SID for the child process */ 931 pid_t sid = setsid(); 932 if (sid < 0) 933 { 934 printf("ERROR: setsid() failed (errno = %d)\n", errno); 935 return 1; 936 } 937 938 /* Redirect standard i/o streams to /dev/null */ 939 freopen ("/dev/null", "r", stdin); 940 freopen ("/dev/null", "w", stdout); 941 freopen ("/dev/null", "w", stderr); 942 853 943 /* close the reading end of the pipe */ 854 944 close(daemon_pipe_fds[0]); … … 857 947 #if defined(USE_BACKTRACE) 858 948 { 859 / / install our signal handler to backtrace the call stack949 /* install our signal handler to backtrace the call stack */ 860 950 struct sigaction sa; 861 951 sa.sa_sigaction = bt_sighandler; … … 880 970 XPCOMGlueStartup (nsnull); 881 971 882 // get the path to the executable 883 char buf [RTPATH_MAX]; 884 char *appPath = NULL; 885 #if defined(DEBUG) 886 appPath = getenv ("VIRTUALBOX_APP_HOME"); 887 if (appPath) 888 RTPathReal (appPath, buf, RTPATH_MAX); 889 else 972 char path [RTPATH_MAX]; 973 path [0] = '\0'; 974 975 nsCOMPtr<nsIFile> nsAppPath; 976 { 977 /* get the path to the executable */ 978 char *appPath = NULL; 979 #if defined (DEBUG) 980 appPath = getenv ("VIRTUALBOX_APP_HOME"); 981 if (appPath) 982 RTPathReal (appPath, path, RTPATH_MAX); 983 else 890 984 #endif 891 RTPathProgram (buf, RTPATH_MAX); 892 appPath = buf; 893 894 nsCOMPtr<nsIFile> nsAppPath; 895 { 985 RTPathProgram (path, RTPATH_MAX); 986 appPath = path; 987 896 988 nsCOMPtr<nsILocalFile> file; 897 989 rc = NS_NewNativeLocalFile (nsEmbedCString (appPath), … … 900 992 nsAppPath = do_QueryInterface (file, &rc); 901 993 } 902 if (NS_FAILED ( rc))903 { 904 printf ("ERROR: failed to create file object! (rc=%08X)\n", rc);994 if (NS_FAILED (rc)) 995 { 996 printf ("ERROR: Failed to create file object! (rc=%08X)\n", rc); 905 997 break; 906 998 } 999 1000 /* get the executable name (will be used below) */ 1001 if (!RTProcGetExecutableName (path, sizeof (path))) 1002 { 1003 printf ("ERROR: Failed to get executable name!\n"); 1004 break; 1005 } 1006 1007 LogFlowFunc (("Will use \"%s\" as server name.\n", path)); 907 1008 908 1009 nsCOMPtr<nsIServiceManager> servMan; … … 910 1011 if (!servMan) 911 1012 { 912 printf ("ERROR: failed to get service manager!\n");1013 printf ("ERROR: Failed to get service manager!\n"); 913 1014 break; 914 1015 } … … 917 1018 if (!registrar) 918 1019 { 919 printf ("ERROR: failed to get component registrar!\n");1020 printf ("ERROR: Failed to get component registrar!\n"); 920 1021 break; 921 1022 } … … 926 1027 if (NS_FAILED (rc)) 927 1028 { 928 printf ("ERROR: failed to register server components! (rc=%08X)\n", rc);1029 printf ("ERROR: Failed to register server components! (rc=%08X)\n", rc); 929 1030 break; 930 1031 } 931 1032 932 / /get the main thread's event queue (afaik, the dconnect service always933 //gets created upon XPCOM startup, so it will use the main (this)934 // thread's event queue to receive IPC events)1033 /* get the main thread's event queue (afaik, the dconnect service always 1034 * gets created upon XPCOM startup, so it will use the main (this) 1035 * thread's event queue to receive IPC events) */ 935 1036 rc = NS_GetMainEventQ (&gEventQ); 936 1037 if (NS_FAILED (rc)) 937 1038 { 938 printf ("ERROR: failed to get the main event queue! (rc=%08X)\n", rc);1039 printf ("ERROR: Failed to get the main event queue! (rc=%08X)\n", rc); 939 1040 break; 940 1041 } … … 943 1044 if (NS_FAILED (rc)) 944 1045 { 945 printf ("ERROR: failed to get IPC service! (rc=%08X)\n", rc);1046 printf ("ERROR: Failed to get IPC service! (rc=%08X)\n", rc); 946 1047 break; 947 1048 } … … 949 1050 NS_ADDREF (gIpcServ = ipcServ); 950 1051 951 rc = gIpcServ->AddName (VIRTUALBOXSERVER_IPCNAME); 1052 /* use the executable name as the server name */ 1053 rc = gIpcServ->AddName (path); 952 1054 if (NS_FAILED (rc)) 953 1055 { 954 printf ("ERROR: failed to register VirtualBoxServer! (rc=%08X)\n", rc);1056 printf ("ERROR: Failed to register VirtualBoxServer! (rc=%08X)\n", rc); 955 1057 NS_RELEASE (gIpcServ); 956 1058 break; … … 958 1060 959 1061 { 960 / / setup signal handling to convert some signals to a quit event1062 /* setup signal handling to convert some signals to a quit event */ 961 1063 struct sigaction sa; 962 1064 sa.sa_handler = signal_handler; … … 1021 1123 } 1022 1124 1023 gIpcServ->RemoveName ( VIRTUALBOXSERVER_IPCNAME);1125 gIpcServ->RemoveName (path); 1024 1126 1025 1127 // stop accepting new events … … 1037 1139 1038 1140 // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM 1039 LogFlow (("VBoxSVC::main(): calling NS_ShutdownXPCOM()...\n"));1141 LogFlowFunc (("Calling NS_ShutdownXPCOM()...\n")); 1040 1142 rc = NS_ShutdownXPCOM (nsnull); 1041 LogFlow (("VBoxSVC::main(): finished NS_ShutdownXPCOM() (rc=%08X).\n", rc));1042 1043 if (NS_FAILED ( rc))1044 printf ("ERROR: failed to shutdown XPCOM! (rc=%08X)\n", rc);1143 LogFlowFunc (("Finished NS_ShutdownXPCOM() (rc=%08X)\n", rc)); 1144 1145 if (NS_FAILED (rc)) 1146 printf ("ERROR: Failed to shutdown XPCOM! (rc=%08X)\n", rc); 1045 1147 1046 1148 XPCOMGlueShutdown(); -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r1128 r1471 215 215 216 216 printf ("Creating VirtualBox object...\n"); 217 CHECK_RC (virtualBox.createLocalObject (CLSID_VirtualBox, 218 "VirtualBoxServer")); 217 CHECK_RC (virtualBox.createLocalObject (CLSID_VirtualBox)); 219 218 if (FAILED (rc)) 220 219 { … … 238 237 239 238 printf ("Creating one more VirtualBox object...\n"); 240 CHECK_RC (virtualBox2.createLocalObject (CLSID_VirtualBox, 241 "VirtualBoxServer")); 239 CHECK_RC (virtualBox2.createLocalObject (CLSID_VirtualBox)); 242 240 if (FAILED (rc)) 243 241 { … … 481 479 #endif 482 480 483 #if 1481 #if 0 484 482 // create a new machine (w/o registering it) 485 483 ///////////////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.