VirtualBox

Changeset 12599 in vbox for trunk/src


Ignore:
Timestamp:
Sep 19, 2008 12:57:35 PM (16 years ago)
Author:
vboxsync
Message:

r=bird: VBoxManage: Variables modified by asynchronous callbacks (signal handlers) should always be declared volatile. As mentioned several times before, if you have to cast a function pointer there is 99% chance you're doing something wrong - don't rely on windows mopping up for you. And finally, please stick to doxygen comments. (A bit more docs wouldn't hurt.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r12596 r12599  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox frontends: VBoxManage (command-line interface)
    4  *
    5  * VBoxManage is VirtualBox's command-line interface. This is its rather
    6  * long source.
     3 * VBoxManage - VirtualBox's command-line interface.
    74 */
    85
     
    78107807}
    78117808
    7812 /*********************************************************************
    7813 * list                                                               *
    7814 *********************************************************************/
     7809/**
     7810 * list                                                               *
     7811 */
    78157812static int handleMetricsList(int argc, char *argv[],
    78167813                             ComPtr<IVirtualBox> aVirtualBox,
     
    78617858}
    78627859
    7863 /*********************************************************************
    7864 * setup                                                              *
    7865 *********************************************************************/
     7860/**
     7861 * Metics setup
     7862 */
    78667863static int handleMetricsSetup(int argc, char *argv[],
    78677864                              ComPtr<IVirtualBox> aVirtualBox,
     
    78737870    com::SafeIfaceArray<IUnknown> objects;
    78747871    ULONG period = 1, samples = 1;
    7875     bool listMatches = false;
     7872    /*bool listMatches = false;*/
    78767873    int i;
    78777874
     
    79227919}
    79237920
    7924 /*********************************************************************
    7925 * query                                                              *
    7926 *********************************************************************/
     7921/**
     7922 * metrics query
     7923 */
    79277924static int handleMetricsQuery(int argc, char *argv[],
    79287925                              ComPtr<IVirtualBox> aVirtualBox,
     
    80098006}
    80108007
    8011 static bool fKeepGoing = true;
     8008/** Used by the handleMetricsCollect loop. */
     8009static bool volatile g_fKeepGoing = true;
    80128010
    80138011#ifdef RT_OS_WINDOWS
    8014 static bool ctrlHandler(DWORD fdwCtrlType)
    8015 {
    8016     switch( fdwCtrlType )
    8017     {
     8012/**
     8013 * Handler routine for catching Ctrl-C, Ctrl-Break and closing of
     8014 * the console.
     8015 *
     8016 * @returns true if handled, false if not handled.
     8017 * @param   dwCtrlType      The type of control signal.
     8018 *
     8019 * @remarks This is called on a new thread.
     8020 */
     8021static BOOL WINAPI ctrlHandler(DWORD dwCtrlType)
     8022{
     8023    switch (dwCtrlType)
     8024    {
    80188025        /* Ctrl-C or Ctrl-Break or Close */
    80198026        case CTRL_C_EVENT:
    80208027        case CTRL_BREAK_EVENT:
    8021         case CTRL_CLOSE_EVENT: 
     8028        case CTRL_CLOSE_EVENT:
    80228029            /* Let's shut down gracefully. */
    8023             fKeepGoing = false;
     8030            ASMAtomicWriteBool(&g_fKeepGoing, true);
    80248031            return true;
    80258032    }
    80268033    /* Don't care about the rest -- let it die a horrible death. */
    80278034    return false;
    8028 } 
     8035}
    80298036#endif /* RT_OS_WINDOWS */
    80308037
    8031 /*********************************************************************
    8032 * collect                                                            *
    8033 *********************************************************************/
     8038/**
     8039 * collect
     8040 */
    80348041static int handleMetricsCollect(int argc, char *argv[],
    80358042                                ComPtr<IVirtualBox> aVirtualBox,
     
    80978104
    80988105#ifdef RT_OS_WINDOWS
    8099     SetConsoleCtrlHandler((PHANDLER_ROUTINE)ctrlHandler, true);
     8106    SetConsoleCtrlHandler(ctrlHandler, true);
    81008107#endif /* RT_OS_WINDOWS */
    81018108
    81028109    RTPrintf("Time stamp   Object     Metric               Value\n");
    81038110
    8104     while (fKeepGoing)
     8111    while (g_fKeepGoing)
    81058112    {
    81068113        RTPrintf("------------ ---------- -------------------- --------------------\n");
     
    81578164
    81588165#ifdef RT_OS_WINDOWS
    8159     SetConsoleCtrlHandler((PHANDLER_ROUTINE)ctrlHandler, false);
     8166    SetConsoleCtrlHandler(ctrlHandler, false);
    81608167#endif /* RT_OS_WINDOWS */
    81618168
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