VirtualBox

Changeset 28263 in vbox


Ignore:
Timestamp:
Apr 13, 2010 3:55:36 PM (15 years ago)
Author:
vboxsync
Message:

PDM: Put pAsyncCompletionTemplates under the ListCritSect.

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMAsyncCompletion.cpp

    r28262 r28263  
    151151     * Add template to the global VM template list.
    152152     */
     153    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
    153154    pTemplate->pNext = pUVM->pdm.s.pAsyncCompletionTemplates;
    154155    if (pUVM->pdm.s.pAsyncCompletionTemplates)
    155156        pUVM->pdm.s.pAsyncCompletionTemplates->pPrev = pTemplate;
    156157    pUVM->pdm.s.pAsyncCompletionTemplates = pTemplate;
     158    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    157159
    158160    *ppTemplate = pTemplate;
     
    398400     */
    399401    PUVM pUVM = pTemplate->pVM->pUVM;
     402    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     403
    400404    PPDMASYNCCOMPLETIONTEMPLATE pPrev = pTemplate->pPrev;
    401405    PPDMASYNCCOMPLETIONTEMPLATE pNext = pTemplate->pNext;
     
    409413        pNext->pPrev = pPrev;
    410414
     415    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
     416
    411417    /*
    412418     * Free the template.
     
    441447     * Unlink it.
    442448     */
    443     PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pVM->pUVM->pdm.s.pAsyncCompletionTemplates;
     449    PUVM pUVM = pVM->pUVM;
     450    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     451    PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pUVM->pdm.s.pAsyncCompletionTemplates;
    444452    while (pTemplate)
    445453    {
     
    451459            int rc = PDMR3AsyncCompletionTemplateDestroy(pTemplateDestroy);
    452460            if (RT_FAILURE(rc))
     461            {
     462                RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    453463                return rc;
     464            }
    454465        }
    455466        else
     
    457468    }
    458469
     470    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    459471    return VINF_SUCCESS;
    460472}
     
    484496     * Unlink it.
    485497     */
    486     PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pVM->pUVM->pdm.s.pAsyncCompletionTemplates;
     498    PUVM pUVM = pVM->pUVM;
     499    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     500    PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pUVM->pdm.s.pAsyncCompletionTemplates;
    487501    while (pTemplate)
    488502    {
     
    494508            int rc = PDMR3AsyncCompletionTemplateDestroy(pTemplateDestroy);
    495509            if (RT_FAILURE(rc))
     510            {
     511                RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    496512                return rc;
     513            }
    497514        }
    498515        else
     
    500517    }
    501518
     519    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    502520    return VINF_SUCCESS;
    503521}
     
    527545     * Unlink it.
    528546     */
    529     PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pVM->pUVM->pdm.s.pAsyncCompletionTemplates;
     547    PUVM pUVM = pVM->pUVM;
     548    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     549    PPDMASYNCCOMPLETIONTEMPLATE pTemplate = pUVM->pdm.s.pAsyncCompletionTemplates;
    530550    while (pTemplate)
    531551    {
     
    537557            int rc = PDMR3AsyncCompletionTemplateDestroy(pTemplateDestroy);
    538558            if (RT_FAILURE(rc))
     559            {
     560                RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    539561                return rc;
     562            }
    540563        }
    541564        else
     
    543566    }
    544567
     568    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    545569    return VINF_SUCCESS;
    546570}
     
    631655                {
    632656                    PUVM pUVM = pVM->pUVM;
    633                     AssertMsg(!pUVM->pdm.s.papAsyncCompletionEndpointClass[pEpClassOps->enmClassType],
     657                    AssertMsg(!pUVM->pdm.s.apAsyncCompletionEndpointClass[pEpClassOps->enmClassType],
    634658                              ("Endpoint class was already initialized\n"));
    635659
    636                     pUVM->pdm.s.papAsyncCompletionEndpointClass[pEpClassOps->enmClassType] = pEndpointClass;
     660                    pUVM->pdm.s.apAsyncCompletionEndpointClass[pEpClassOps->enmClassType] = pEndpointClass;
    637661                    LogFlowFunc((": Initialized endpoint class \"%s\" rc=%Rrc\n", pEpClassOps->pcszName, rc));
    638662                    return VINF_SUCCESS;
     
    674698
    675699    /* Free the memory of the class finally and clear the entry in the class array. */
    676     pVM->pUVM->pdm.s.papAsyncCompletionEndpointClass[pEndpointClass->pEndpointOps->enmClassType] = NULL;
     700    pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[pEndpointClass->pEndpointOps->enmClassType] = NULL;
    677701    MMR3HeapFree(pEndpointClass);
    678702}
     
    693717    VM_ASSERT_EMT(pVM);
    694718
    695     do
    696     {
    697         /* Allocate array for global class data. */
    698         rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_ASYNC_COMPLETION,
    699                               sizeof(PPDMASYNCCOMPLETIONEPCLASS) * PDMASYNCCOMPLETIONEPCLASSTYPE_MAX,
    700                               (void **)&pUVM->pdm.s.papAsyncCompletionEndpointClass);
    701         if (RT_FAILURE(rc))
    702             break;
    703 
    704         PCFGMNODE pCfgRoot = CFGMR3GetRoot(pVM);
    705         PCFGMNODE pCfgAsyncCompletion = CFGMR3GetChild(CFGMR3GetChild(pCfgRoot, "PDM"), "AsyncCompletion");
    706 
    707         rc = pdmR3AsyncCompletionEpClassInit(pVM, &g_PDMAsyncCompletionEndpointClassFile, pCfgAsyncCompletion);
    708         if (RT_FAILURE(rc))
    709             break;
    710 
    711         /* Put other classes here. */
    712     } while (0);
     719    PCFGMNODE pCfgRoot            = CFGMR3GetRoot(pVM);
     720    PCFGMNODE pCfgAsyncCompletion = CFGMR3GetChild(CFGMR3GetChild(pCfgRoot, "PDM"), "AsyncCompletion");
     721
     722    rc = pdmR3AsyncCompletionEpClassInit(pVM, &g_PDMAsyncCompletionEndpointClassFile, pCfgAsyncCompletion);
    713723
    714724    LogFlowFunc((": pVM=%p rc=%Rrc\n", pVM, rc));
     
    728738    PUVM pUVM = pVM->pUVM;
    729739
    730     if (pUVM->pdm.s.papAsyncCompletionEndpointClass)
    731     {
    732         pdmR3AsyncCompletionEpClassTerminate(pUVM->pdm.s.papAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE]);
    733         MMR3HeapFree(pUVM->pdm.s.papAsyncCompletionEndpointClass);
    734     }
     740    for (size_t i = 0; i < RT_ELEMENTS(pUVM->pdm.s.apAsyncCompletionEndpointClass); i++)
     741        if (pUVM->pdm.s.apAsyncCompletionEndpointClass[i])
     742            pdmR3AsyncCompletionEpClassTerminate(pUVM->pdm.s.apAsyncCompletionEndpointClass[i]);
     743
    735744    return VINF_SUCCESS;
    736745}
     
    880889    PVM  pVM  = pTemplate->pVM;
    881890    PUVM pUVM = pVM->pUVM;
    882     PPDMASYNCCOMPLETIONEPCLASS  pEndpointClass = pUVM->pdm.s.papAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];
     891    PPDMASYNCCOMPLETIONEPCLASS  pEndpointClass = pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];
    883892    PPDMASYNCCOMPLETIONENDPOINT pEndpoint = NULL;
    884893
  • trunk/src/VBox/VMM/PDMAsyncCompletionInternal.h

    r28065 r28263  
    55
    66/*
    7  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919 * additional information or have any questions.
    2020 */
    21 #ifndef __PDMAsyncCompletionInternal_h
    22 #define __PDMAsyncCompletionInternal_h
    23 
    24 #include "PDMInternal.h"
    25 #include <iprt/cdefs.h>
     21
     22#ifndef ___PDMAsyncCompletionInternal_h
     23#define ___PDMAsyncCompletionInternal_h
     24
    2625#include <iprt/critsect.h>
    2726#include <iprt/memcache.h>
     
    3130#include <VBox/stam.h>
    3231#include <VBox/pdmasynccompletion.h>
     32#include "PDMInternal.h"
    3333
    3434RT_C_DECLS_BEGIN
    3535
    36 /**
    37  * Supported endpoint classes.
    38  */
    39 typedef enum PDMASYNCCOMPLETIONEPCLASSTYPE
    40 {
    41     /** File class. */
    42     PDMASYNCCOMPLETIONEPCLASSTYPE_FILE = 0,
    43     /** Number of supported classes. */
    44     PDMASYNCCOMPLETIONEPCLASSTYPE_MAX,
    45     /** 32bit hack. */
    46     PDMASYNCCOMPLETIONEPCLASSTYPE_32BIT_HACK = 0x7fffffff
    47 } PDMASYNCCOMPLETIONEPCLASSTYPE;
    4836
    4937/**
     
    274262extern const PDMASYNCCOMPLETIONEPCLASSOPS g_PDMAsyncCompletionEndpointClassFile;
    275263
    276 #endif /* __PDMAsyncCompletionInternal_h */
     264#endif /* !___PDMAsyncCompletionInternal_h */
     265
  • trunk/src/VBox/VMM/PDMInternal.h

    r28262 r28263  
    9191/** Pointer to an USB HUB registration record. */
    9292typedef struct PDMUSBHUB *PPDMUSBHUB;
     93
     94/**
     95 * Supported asynchronous completion endpoint classes.
     96 */
     97typedef enum PDMASYNCCOMPLETIONEPCLASSTYPE
     98{
     99    /** File class. */
     100    PDMASYNCCOMPLETIONEPCLASSTYPE_FILE = 0,
     101    /** Number of supported classes. */
     102    PDMASYNCCOMPLETIONEPCLASSTYPE_MAX,
     103    /** 32bit hack. */
     104    PDMASYNCCOMPLETIONEPCLASSTYPE_32BIT_HACK = 0x7fffffff
     105} PDMASYNCCOMPLETIONEPCLASSTYPE;
    93106
    94107/**
     
    10001013
    10011014
     1015
    10021016/**
    10031017 * PDM data kept in the UVM.
     
    10161030    /** Tail of the PDM Thread list. (singly linked) */
    10171031    R3PTRTYPE(PPDMTHREAD)           pThreadsTail;
    1018 
    1019     /** @name   PDM Async Completion
    1020      * @{ */
    1021     /** Pointer to the array of supported endpoint classes. */
    1022     R3PTRTYPE(PPDMASYNCCOMPLETIONEPCLASS *)  papAsyncCompletionEndpointClass;
    1023     /** Head of the templates. (singly linked) */
    1024     R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates;
    1025     /** @} */
    10261032
    10271033    /** Lock protecting the lists below it. */
     
    10311037    /** List of initialized critical sections. (LIFO) */
    10321038    R3PTRTYPE(PPDMCRITSECTINT)      pCritSects;
     1039
     1040    /** @name   PDM Async Completion
     1041     * @{ */
     1042    /** Pointer to the array of supported endpoint classes. */
     1043    PPDMASYNCCOMPLETIONEPCLASS      apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_MAX];
     1044    /** Head of the templates. Singly linked, protected by ListCritSect. */
     1045    R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates;
     1046    /** @} */
    10331047
    10341048} PDMUSERPERVM;
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