VirtualBox

Ignore:
Timestamp:
Jan 25, 2010 2:21:13 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56881
Message:

PDM,*: Redid the PDM structure versions. Check the instance and helper versions in every device and driver constructor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DrvNamedPipe.cpp

    r25985 r26001  
    383383}
    384384
     385/* -=-=-=-=- PDMDRVREG -=-=-=-=- */
     386
     387/**
     388 * Power off a named pipe stream driver instance.
     389 *
     390 * This does most of the destruction work, to avoid ordering dependencies.
     391 *
     392 * @param   pDrvIns     The driver instance data.
     393 */
     394static DECLCALLBACK(void) drvNamedPipePowerOff(PPDMDRVINS pDrvIns)
     395{
     396    PDRVNAMEDPIPE pThis = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
     397    LogFlow(("%s: %s\n", __FUNCTION__, pThis->pszLocation));
     398
     399    pThis->fShutdown = true;
     400
     401#ifdef RT_OS_WINDOWS
     402    if (pThis->NamedPipe != INVALID_HANDLE_VALUE)
     403    {
     404        if (pThis->fIsServer)
     405        {
     406            FlushFileBuffers(pThis->NamedPipe);
     407            DisconnectNamedPipe(pThis->NamedPipe);
     408        }
     409
     410        CloseHandle(pThis->NamedPipe);
     411        pThis->NamedPipe = INVALID_HANDLE_VALUE;
     412        CloseHandle(pThis->OverlappedRead.hEvent);
     413        CloseHandle(pThis->OverlappedWrite.hEvent);
     414    }
     415    if (pThis->fIsServer)
     416    {
     417        /* Wake up listen thread */
     418        RTSemEventSignal(pThis->ListenSem);
     419        RTSemEventDestroy(pThis->ListenSem);
     420    }
     421#else /* !RT_OS_WINDOWS */
     422    if (pThis->fIsServer)
     423    {
     424        if (pThis->LocalSocketServer != NIL_RTSOCKET)
     425            close(pThis->LocalSocketServer);
     426        if (pThis->pszLocation)
     427            RTFileDelete(pThis->pszLocation);
     428    }
     429    else
     430    {
     431        if (pThis->LocalSocket != NIL_RTSOCKET)
     432            close(pThis->LocalSocket);
     433    }
     434#endif /* !RT_OS_WINDOWS */
     435}
     436
     437
     438/**
     439 * Destruct a named pipe stream driver instance.
     440 *
     441 * Most VM resources are freed by the VM. This callback is provided so that
     442 * any non-VM resources can be freed correctly.
     443 *
     444 * @param   pDrvIns     The driver instance data.
     445 */
     446static DECLCALLBACK(void) drvNamedPipeDestruct(PPDMDRVINS pDrvIns)
     447{
     448    PDRVNAMEDPIPE pThis = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
     449    LogFlow(("%s: %s\n", __FUNCTION__, pThis->pszLocation));
     450    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
     451
     452    if (pThis->ListenThread)
     453    {   RTThreadWait(pThis->ListenThread, 250, NULL);
     454        if (pThis->ListenThread != NIL_RTTHREAD)
     455            LogRel(("NamedPipe%d: listen thread did not terminate\n", pDrvIns->iInstance));
     456    }
     457
     458    if (pThis->pszLocation)
     459        MMR3HeapFree(pThis->pszLocation);
     460}
     461
    385462
    386463/**
     
    394471    char *pszLocation = NULL;
    395472    PDRVNAMEDPIPE pThis = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
     473    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    396474
    397475    /*
     
    421499    {
    422500        rc = VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    423         goto out;
     501        goto l_out;
    424502    }
    425503
     
    428506    {
    429507        AssertMsgFailed(("Configuration error: query \"Location\" resulted in %Rrc.\n", rc));
    430         goto out;
     508        goto l_out;
    431509    }
    432510    pThis->pszLocation = pszLocation;
     
    437515    {
    438516        AssertMsgFailed(("Configuration error: query \"IsServer\" resulted in %Rrc.\n", rc));
    439         goto out;
     517        goto l_out;
    440518    }
    441519    pThis->fIsServer = fIsServer;
     
    509587#endif /* !RT_OS_WINDOWS */
    510588
    511 out:
     589l_out:
    512590    if (RT_FAILURE(rc))
    513591    {
     
    520598    LogRel(("NamedPipe: location %s, %s\n", pszLocation, fIsServer ? "server" : "client"));
    521599    return VINF_SUCCESS;
    522 }
    523 
    524 
    525 /**
    526  * Destruct a named pipe stream driver instance.
    527  *
    528  * Most VM resources are freed by the VM. This callback is provided so that
    529  * any non-VM resources can be freed correctly.
    530  *
    531  * @param   pDrvIns     The driver instance data.
    532  */
    533 static DECLCALLBACK(void) drvNamedPipeDestruct(PPDMDRVINS pDrvIns)
    534 {
    535     PDRVNAMEDPIPE pThis = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
    536     LogFlow(("%s: %s\n", __FUNCTION__, pThis->pszLocation));
    537 
    538     if (pThis->ListenThread)
    539     {
    540         RTThreadWait(pThis->ListenThread, 250, NULL);
    541         if (pThis->ListenThread != NIL_RTTHREAD)
    542             LogRel(("NamedPipe%d: listen thread did not terminate\n", pDrvIns->iInstance));
    543     }
    544 
    545     if (pThis->pszLocation)
    546         MMR3HeapFree(pThis->pszLocation);
    547 }
    548 
    549 
    550 /**
    551  * Power off a named pipe stream driver instance.
    552  *
    553  * This does most of the destruction work, to avoid ordering dependencies.
    554  *
    555  * @param   pDrvIns     The driver instance data.
    556  */
    557 static DECLCALLBACK(void) drvNamedPipePowerOff(PPDMDRVINS pDrvIns)
    558 {
    559     PDRVNAMEDPIPE pThis = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
    560     LogFlow(("%s: %s\n", __FUNCTION__, pThis->pszLocation));
    561 
    562     pThis->fShutdown = true;
    563 
    564 #ifdef RT_OS_WINDOWS
    565     if (pThis->NamedPipe != INVALID_HANDLE_VALUE)
    566     {
    567         if (pThis->fIsServer)
    568         {
    569             FlushFileBuffers(pThis->NamedPipe);
    570             DisconnectNamedPipe(pThis->NamedPipe);
    571         }
    572 
    573         CloseHandle(pThis->NamedPipe);
    574         pThis->NamedPipe = INVALID_HANDLE_VALUE;
    575         CloseHandle(pThis->OverlappedRead.hEvent);
    576         CloseHandle(pThis->OverlappedWrite.hEvent);
    577     }
    578     if (pThis->fIsServer)
    579     {
    580         /* Wake up listen thread */
    581         RTSemEventSignal(pThis->ListenSem);
    582         RTSemEventDestroy(pThis->ListenSem);
    583     }
    584 #else /* !RT_OS_WINDOWS */
    585     if (pThis->fIsServer)
    586     {
    587         if (pThis->LocalSocketServer != NIL_RTSOCKET)
    588             close(pThis->LocalSocketServer);
    589         if (pThis->pszLocation)
    590             RTFileDelete(pThis->pszLocation);
    591     }
    592     else
    593     {
    594         if (pThis->LocalSocket != NIL_RTSOCKET)
    595             close(pThis->LocalSocket);
    596     }
    597 #endif /* !RT_OS_WINDOWS */
    598600}
    599601
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette