VirtualBox

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


Ignore:
Timestamp:
Apr 19, 2010 8:45:03 AM (15 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Use RTListForEach; small bugfixes.

File:
1 edited

Legend:

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

    r28434 r28446  
    240240static DECLCALLBACK(void) VBoxServiceControlTerm(void)
    241241{
    242     /* Shutdown spawned processes threads. */
    243     PVBOXSERVICECTRLTHREAD pNode = RTListNodeGetFirst(&g_GuestControlExecThreads, VBOXSERVICECTRLTHREAD, Node);
    244     while (pNode)
    245     {
     242    /* Signal all threads that we want to shutdown. */
     243    PVBOXSERVICECTRLTHREAD pNode;
     244    RTListForEach(&g_GuestControlExecThreads, pNode, VBOXSERVICECTRLTHREAD, Node)
    246245        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)
     246
     247    /* Wait for threads to shutdown. */
     248    RTListForEach(&g_GuestControlExecThreads, pNode, VBOXSERVICECTRLTHREAD, Node)
    254249    {
    255250        if (pNode->Thread != NIL_RTTHREAD)
     
    260255        }
    261256        VBoxServiceControlExecDestroyThreadData(pNode);
    262         if (RTListNodeIsLast(&g_GuestControlExecThreads, &pNode->Node))
    263             break;
    264         pNode = RTListNodeGetNext(&pNode->Node, VBOXSERVICECTRLTHREAD, Node);
    265     }
    266 
     257    }
     258
     259    /* Finally destroy thread list. */
    267260    pNode = RTListNodeGetFirst(&g_GuestControlExecThreads, VBOXSERVICECTRLTHREAD, Node);
    268261    while (pNode)
    269262    {
     263        PVBOXSERVICECTRLTHREAD pNext = RTListNodeGetNext(&pNode->Node, VBOXSERVICECTRLTHREAD, Node);
     264
    270265        RTListNodeRemove(&pNode->Node);
    271266        RTMemFree(pNode);
    272         if (RTListNodeIsLast(&g_GuestControlExecThreads, &pNode->Node))
     267
     268        if (pNext && RTListNodeIsLast(&g_GuestControlExecThreads, &pNext->Node))
    273269              break;
    274270
    275         PVBOXSERVICECTRLTHREAD pNext = RTListNodeGetNext(&pNode->Node, VBOXSERVICECTRLTHREAD, Node);
    276271        pNode = pNext;
    277272    }
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