VirtualBox

Changeset 28420 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Apr 16, 2010 1:32:14 PM (15 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Use RTList instead of STL.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r28409 r28420  
    4848static uint32_t             g_GuestControlSvcClientID = 0;
    4949/** List of spawned processes */
    50 GuestCtrlExecThreads        g_GuestControlExecThreads;
     50RTLISTNODE                  g_GuestControlExecThreads;
    5151
    5252
     
    9494    }
    9595
     96    /* Init thread list. */
     97    RTListInit(&g_GuestControlExecThreads);
    9698    return rc;
    9799}
     
    239241{
    240242    /* Shutdown spawned processes threads. */
    241     for (GuestCtrlExecListIter it = g_GuestControlExecThreads.begin();
    242          it != g_GuestControlExecThreads.end(); it++)
    243     {
    244         ASMAtomicXchgBool(&(*it)->fShutdown, true);
    245     }
    246    
    247     for (GuestCtrlExecListIter it = g_GuestControlExecThreads.begin();
    248          it != g_GuestControlExecThreads.end(); it++)
    249     {
    250         if ((*it)->Thread != NIL_RTTHREAD)
    251         {
    252             int rc2 = RTThreadWait((*it)->Thread, 30 * 1000 /* Wait 30 second */, NULL);
     243    PVBOXSERVICECTRLTHREAD pNode = RTListNodeGetFirst(&g_GuestControlExecThreads, VBOXSERVICECTRLTHREAD, Node);
     244    while (pNode)
     245    {
     246        ASMAtomicXchgBool(&pNode->fShutdown, true);
     247        if (RTListNodeIsLast(&g_GuestControlExecThreads, &pNode->Node))
     248            break;
     249        pNode = RTListNodeGetNext(&pNode->Node, VBOXSERVICECTRLTHREAD, Node);
     250    }
     251
     252    pNode = RTListNodeGetFirst(&g_GuestControlExecThreads, VBOXSERVICECTRLTHREAD, Node);
     253    while (pNode)
     254    {
     255        if (pNode->Thread != NIL_RTTHREAD)
     256        {
     257            int rc2 = RTThreadWait(pNode->Thread, 30 * 1000 /* Wait 30 seconds max. */, NULL);
    253258            if (RT_FAILURE(rc2))
    254                 VBoxServiceError("Control: Thread (PID: %u) failed to stop; rc2=%Rrc\n", (*it)->uPID, rc2);
    255         }
    256         VBoxServiceControlExecDestroyThreadData((*it));
    257     }
    258 
    259     for (GuestCtrlExecListIter it = g_GuestControlExecThreads.begin();
    260          it != g_GuestControlExecThreads.end(); it++)
    261             RTMemFree((*it));
    262 
    263     g_GuestControlExecThreads.clear();
     259                VBoxServiceError("Control: Thread (PID: %u) failed to stop; rc2=%Rrc\n", pNode->uPID, rc2);
     260        }
     261        VBoxServiceControlExecDestroyThreadData(pNode);
     262        if (RTListNodeIsLast(&g_GuestControlExecThreads, &pNode->Node))
     263            break;
     264        pNode = RTListNodeGetNext(&pNode->Node, VBOXSERVICECTRLTHREAD, Node);
     265    }
     266
     267    pNode = RTListNodeGetFirst(&g_GuestControlExecThreads, VBOXSERVICECTRLTHREAD, Node);
     268    while (pNode)
     269    {
     270        RTListNodeRemove(&pNode->Node);
     271        RTMemFree(pNode);
     272        if (RTListNodeIsLast(&g_GuestControlExecThreads, &pNode->Node))
     273              break;
     274       
     275        PVBOXSERVICECTRLTHREAD pNext = RTListNodeGetNext(&pNode->Node, VBOXSERVICECTRLTHREAD, Node);       
     276        pNode = pNext;
     277    }
     278
    264279    VbglR3GuestCtrlDisconnect(g_GuestControlSvcClientID);
    265280    g_GuestControlSvcClientID = 0;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp

    r28410 r28420  
    5050using namespace guestControl;
    5151
    52 extern GuestCtrlExecThreads g_GuestControlExecThreads;
     52extern RTLISTNODE g_GuestControlExecThreads;
    5353
    5454/**
     
    537537{
    538538    AssertPtr(pThread);
     539
     540    pThread->Node.pPrev = NULL;
     541    pThread->Node.pNext = NULL;
    539542
    540543    pThread->fShutdown = false;
     
    802805                else
    803806                {
    804                     g_GuestControlExecThreads.push_back(pThread);
     807                    /*rc =*/ RTListAppend(&g_GuestControlExecThreads, &pThread->Node);
    805808                }
    806809            }
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r28409 r28420  
    2828# include <process.h> /* Needed for file version information. */
    2929#endif
     30
    3031#ifdef VBOX_WITH_GUEST_CONTROL
    31 # include <list>
     32# include <iprt/list.h>
    3233#endif
    3334
     
    132133typedef struct
    133134{
     135    /** Node. */
     136    RTLISTNODE                 Node;
    134137    /** The worker thread. */
    135138    RTTHREAD                   Thread;
     
    228231
    229232#ifdef VBOX_WITH_GUEST_CONTROL
    230 using namespace std;
    231 
    232 typedef std::list< PVBOXSERVICECTRLTHREAD > GuestCtrlExecThreads;
    233 typedef std::list< PVBOXSERVICECTRLTHREAD >::iterator GuestCtrlExecListIter;
    234 typedef std::list< PVBOXSERVICECTRLTHREAD >::const_iterator GuestCtrlExecListIterConst;
    235 
    236233extern int VBoxServiceControlExecProcess(uint32_t uContext, const char *pszCmd, uint32_t uFlags,
    237234                                         const char *pszArgs, uint32_t uNumArgs,                                           
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