Changeset 51503 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jun 3, 2014 7:24:46 AM (11 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r50051 r51503 490 490 if (!g_aServices[j].fPreInited) 491 491 { 492 int rc = g_aServices[j].pDesc->pfnPreInit(); 493 if (RT_FAILURE(rc)) 494 return VBoxServiceError("Service '%s' failed pre-init: %Rrc\n", g_aServices[j].pDesc->pszName, rc); 492 if (g_aServices[j].pDesc->pfnPreInit != NULL) 493 { 494 int rc = g_aServices[j].pDesc->pfnPreInit(); 495 if (RT_FAILURE(rc)) 496 return VBoxServiceError("Service '%s' failed pre-init: %Rrc\n", 497 g_aServices[j].pDesc->pszName, rc); 498 } 495 499 g_aServices[j].fPreInited = true; 496 500 } … … 556 560 VBoxServiceVerbose(2, "Initializing services ...\n"); 557 561 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++) 558 if (g_aServices[j].fEnabled )562 if (g_aServices[j].fEnabled && g_aServices[j].pDesc->pfnInit != NULL) 559 563 { 560 564 rc = g_aServices[j].pDesc->pfnInit(); … … 601 605 * to exit the loop before we skipped the fShutdown check 602 606 * below the service will fail to start! */ 607 /** @todo This presumably means either a one-shot service or that 608 * something has gone wrong. In the second case treating it as failure 609 * to start is probably right, so we need a way to signal the first. */ 603 610 RTThreadUserWait(g_aServices[j].Thread, 60 * 1000); 604 611 if (g_aServices[j].fShutdown) … … 640 647 */ 641 648 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++) 642 if (g_aServices[j].fStarted )649 if (g_aServices[j].fStarted && g_aServices[j].pDesc->pfnStop != NULL) 643 650 { 644 651 VBoxServiceVerbose(3, "Calling stop function for service '%s' ...\n", g_aServices[j].pDesc->pszName); … … 656 663 if (!g_aServices[j].fEnabled) /* Only stop services which were started before. */ 657 664 continue; 658 if (g_aServices[j].Thread != NIL_RTTHREAD) 665 if ( g_aServices[j].Thread != NIL_RTTHREAD 666 && g_aServices[j].pDesc->pfnStop != NULL) 659 667 { 660 668 VBoxServiceVerbose(2, "Waiting for service '%s' to stop ...\n", g_aServices[j].pDesc->pszName); … … 676 684 } 677 685 } 678 VBoxServiceVerbose(3, "Terminating service '%s' (%d) ...\n", g_aServices[j].pDesc->pszName, j); 679 g_aServices[j].pDesc->pfnTerm(); 686 if (g_aServices[j].pDesc->pfnTerm != NULL) 687 { 688 VBoxServiceVerbose(3, "Terminating service '%s' (%d) ...\n", 689 g_aServices[j].pDesc->pszName, j); 690 g_aServices[j].pDesc->pfnTerm(); 691 } 680 692 } 681 693 … … 906 918 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++) 907 919 { 920 if (g_aServices[j].pDesc->pfnOption == NULL) 921 continue; 908 922 rc = g_aServices[j].pDesc->pfnOption(NULL, argc, argv, &i); 909 923 fFound = rc == VINF_SUCCESS; … … 977 991 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++) 978 992 { 993 if (g_aServices[j].pDesc->pfnOption == NULL) 994 continue; 979 995 rc = g_aServices[j].pDesc->pfnOption(&psz, argc, argv, &i); 980 996 fFound = rc == VINF_SUCCESS; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
r50461 r51503 68 68 /** The Shared Folders service client ID. */ 69 69 static uint32_t g_SharedFoldersSvcClientID = 0; 70 71 /** @copydoc VBOXSERVICE::pfnPreInit */72 static DECLCALLBACK(int) VBoxServiceAutoMountPreInit(void)73 {74 return VINF_SUCCESS;75 }76 77 78 /** @copydoc VBOXSERVICE::pfnOption */79 static DECLCALLBACK(int) VBoxServiceAutoMountOption(const char **ppszShort, int argc, char **argv, int *pi)80 {81 NOREF(ppszShort);82 NOREF(argc);83 NOREF(argv);84 NOREF(pi);85 86 return -1;87 }88 89 70 90 71 /** @copydoc VBOXSERVICE::pfnInit */ … … 618 599 NULL, 619 600 /* methods */ 620 VBoxServiceAutoMountPreInit, 621 VBoxServiceAutoMountOption, 601 /* pfnPreInit */ 602 NULL, 603 /* pfnOption */ 604 NULL, 622 605 VBoxServiceAutoMountInit, 623 606 VBoxServiceAutoMountWorker, -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceBalloon.cpp
r44528 r51503 224 224 225 225 return VINF_SUCCESS; 226 }227 228 229 /** @copydoc VBOXSERVICE::pfnPreInit */230 static DECLCALLBACK(int) VBoxServiceBalloonPreInit(void)231 {232 return VINF_SUCCESS;233 }234 235 236 /** @copydoc VBOXSERVICE::pfnOption */237 static DECLCALLBACK(int) VBoxServiceBalloonOption(const char **ppszShort, int argc, char **argv, int *pi)238 {239 NOREF(ppszShort);240 NOREF(argc);241 NOREF(argv);242 NOREF(pi);243 244 return -1;245 226 } 246 227 … … 396 377 } 397 378 398 /** @copydoc VBOXSERVICE::pfnTerm */399 static DECLCALLBACK(void) VBoxServiceBalloonTerm(void)400 {401 VBoxServiceVerbose(3, "VBoxServiceBalloonTerm\n");402 return;403 }404 405 379 406 380 /** @copydoc VBOXSERVICE::pfnStop */ … … 425 399 NULL, 426 400 /* methods */ 427 VBoxServiceBalloonPreInit, 428 VBoxServiceBalloonOption, 401 /* pfnPreInit */ 402 NULL, 403 /* pfnOption */ 404 NULL, 429 405 VBoxServiceBalloonInit, 430 406 VBoxServiceBalloonWorker, 431 407 VBoxServiceBalloonStop, 432 VBoxServiceBalloonTerm 408 /* pfnTerm */ 409 NULL 433 410 }; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceCpuHotPlug.cpp
r50286 r51503 395 395 } 396 396 #endif /* RT_OS_LINUX */ 397 398 399 /** @copydoc VBOXSERVICE::pfnPreInit */400 static DECLCALLBACK(int) VBoxServiceCpuHotPlugPreInit(void)401 {402 return VINF_SUCCESS;403 }404 405 406 /** @copydoc VBOXSERVICE::pfnOption */407 static DECLCALLBACK(int) VBoxServiceCpuHotPlugOption(const char **ppszShort, int argc, char **argv, int *pi)408 {409 NOREF(ppszShort);410 NOREF(argc);411 NOREF(argv);412 NOREF(pi);413 414 return -1;415 }416 417 418 /** @copydoc VBOXSERVICE::pfnInit */419 static DECLCALLBACK(int) VBoxServiceCpuHotPlugInit(void)420 {421 return VINF_SUCCESS;422 }423 397 424 398 … … 620 594 621 595 622 /** @copydoc VBOXSERVICE::pfnTerm */623 static DECLCALLBACK(void) VBoxServiceCpuHotPlugTerm(void)624 {625 return;626 }627 628 629 596 /** 630 597 * The 'timesync' service description. … … 641 608 NULL, 642 609 /* methods */ 643 VBoxServiceCpuHotPlugPreInit, 644 VBoxServiceCpuHotPlugOption, 645 VBoxServiceCpuHotPlugInit, 610 /* pfnPreInit */ 611 NULL, 612 /* pfnOption */ 613 NULL, 614 /* pnfInit */ 615 NULL, 646 616 VBoxServiceCpuHotPlugWorker, 647 617 VBoxServiceCpuHotPlugStop, 648 VBoxServiceCpuHotPlugTerm 618 /* pfnTerm */ 619 NULL 649 620 }; 650 621 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r47335 r51503 46 46 47 47 /** 48 * Called before parsing arguments. 48 * Called before parsing arguments. Optional. 49 49 * @returns VBox status code. 50 50 */ … … 52 52 53 53 /** 54 * Tries to parse the given command line option. 54 * Tries to parse the given command line option. Optional. 55 55 * 56 56 * @returns 0 if we parsed, -1 if it didn't and anything else means exit. … … 64 64 65 65 /** 66 * Called before parsing arguments. 66 * Called before parsing arguments. Optional. 67 67 * @returns VBox status code. 68 68 */ … … 79 79 80 80 /** 81 * Stop an service. 81 * Stop an service. If the service can safely be stopped at any time this 82 * may be left NULL. 82 83 */ 83 84 DECLCALLBACKMEMBER(void, pfnStop)(void); 84 85 85 86 /** 86 * Does termination cleanups. 87 * Does termination cleanups. Optional. 87 88 * 88 89 * @remarks This may be called even if pfnInit hasn't been called! -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePageSharing.cpp
r46593 r51503 525 525 #endif 526 526 527 /** @copydoc VBOXSERVICE::pfnPreInit */528 static DECLCALLBACK(int) VBoxServicePageSharingPreInit(void)529 {530 return VINF_SUCCESS;531 }532 533 534 /** @copydoc VBOXSERVICE::pfnOption */535 static DECLCALLBACK(int) VBoxServicePageSharingOption(const char **ppszShort, int argc, char **argv, int *pi)536 {537 NOREF(ppszShort);538 NOREF(argc);539 NOREF(argv);540 NOREF(pi);541 542 return -1;543 }544 545 546 527 /** @copydoc VBOXSERVICE::pfnInit */ 547 528 static DECLCALLBACK(int) VBoxServicePageSharingInit(void) … … 731 712 #endif /* RT_OS_WINDOWS */ 732 713 733 /** @copydoc VBOXSERVICE::pfnTerm */734 static DECLCALLBACK(void) VBoxServicePageSharingTerm(void)735 {736 VBoxServiceVerbose(3, "VBoxServicePageSharingTerm\n");737 }738 739 740 714 /** @copydoc VBOXSERVICE::pfnStop */ 741 715 static DECLCALLBACK(void) VBoxServicePageSharingStop(void) … … 759 733 NULL, 760 734 /* methods */ 761 VBoxServicePageSharingPreInit, 762 VBoxServicePageSharingOption, 735 /* pfnPreInit */ 736 NULL, 737 /* pfnOption */ 738 NULL, 763 739 VBoxServicePageSharingInit, 764 740 #ifdef RT_OS_WINDOWS … … 768 744 #endif 769 745 VBoxServicePageSharingStop, 770 VBoxServicePageSharingTerm 746 /* pfnTerm */ 747 NULL 771 748 }; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp
r48311 r51503 83 83 /** The semaphore we're blocking on. */ 84 84 static RTSEMEVENTMULTI g_VMStatEvent = NIL_RTSEMEVENTMULTI; 85 86 87 /** @copydoc VBOXSERVICE::pfnPreInit */88 static DECLCALLBACK(int) VBoxServiceVMStatsPreInit(void)89 {90 return VINF_SUCCESS;91 }92 93 94 /** @copydoc VBOXSERVICE::pfnOption */95 static DECLCALLBACK(int) VBoxServiceVMStatsOption(const char **ppszShort, int argc, char **argv, int *pi)96 {97 NOREF(ppszShort);98 NOREF(argc);99 NOREF(argv);100 NOREF(pi);101 102 return -1;103 }104 85 105 86 … … 681 662 682 663 683 /** @copydoc VBOXSERVICE::pfnTerm */684 static DECLCALLBACK(void) VBoxServiceVMStatsTerm(void)685 {686 VBoxServiceVerbose(3, "VBoxServiceVMStatsTerm\n");687 return;688 }689 690 691 664 /** @copydoc VBOXSERVICE::pfnStop */ 692 665 static DECLCALLBACK(void) VBoxServiceVMStatsStop(void) … … 710 683 NULL, 711 684 /* methods */ 712 VBoxServiceVMStatsPreInit, 713 VBoxServiceVMStatsOption, 685 /* pfnPreInit */ 686 NULL, 687 /* pfnOption */ 688 NULL, 714 689 VBoxServiceVMStatsInit, 715 690 VBoxServiceVMStatsWorker, 716 691 VBoxServiceVMStatsStop, 717 VBoxServiceVMStatsTerm 692 /* pfnTerm */ 693 NULL 718 694 }; 719 695 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r50571 r51503 155 155 156 156 157 /** @copydoc VBOXSERVICE::pfnPreInit */158 static DECLCALLBACK(int) VBoxServiceVMInfoPreInit(void)159 {160 return VINF_SUCCESS;161 }162 163 164 157 /** @copydoc VBOXSERVICE::pfnOption */ 165 158 static DECLCALLBACK(int) VBoxServiceVMInfoOption(const char **ppszShort, int argc, char **argv, int *pi) … … 1592 1585 , 1593 1586 /* methods */ 1594 VBoxServiceVMInfoPreInit, 1587 /* pfnPreInit */ 1588 NULL, 1595 1589 VBoxServiceVMInfoOption, 1596 1590 VBoxServiceVMInfoInit,
Note:
See TracChangeset
for help on using the changeset viewer.