VirtualBox

Changeset 91040 in vbox for trunk/src


Ignore:
Timestamp:
Aug 31, 2021 5:40:36 PM (3 years ago)
Author:
vboxsync
Message:

Audio/Validation Kit: Got rid of the embedded (and probably wrong) failure reply struct and replaced it with ATSPKTREPFAIL so that clients also can interpret it more easily. ​bugref:10008

Location:
trunk/src/VBox/Devices/Audio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTestService.cpp

    r91039 r91040  
    356356{
    357357    RT_NOREF(pPktHdr);
    358     union
    359     {
    360         ATSPKTHDR   Hdr;
    361         int         rc;
    362         char        ach[256];
    363     } uPkt;
    364     RT_ZERO(uPkt);
    365 
    366     size_t cchDetail = RTStrPrintfV(&uPkt.ach[sizeof(ATSPKTHDR)],
    367                                     sizeof(uPkt) - sizeof(ATSPKTHDR),
    368                                     pszDetailFmt, va);
    369 
    370     uPkt.rc = rcReq;
    371 
    372     return atsReplyInternal(pThis, pInst, &uPkt.Hdr, pszOpcode, sizeof(int) + cchDetail + 1);
     358
     359    ATSPKTREPFAIL Rep;
     360    RT_ZERO(Rep);
     361
     362    size_t cchDetail = RTStrPrintfV(Rep.ach, sizeof(Rep.ach), pszDetailFmt, va);
     363
     364    Rep.rc = rcReq;
     365
     366    return atsReplyInternal(pThis, pInst, &Rep.Hdr, pszOpcode, sizeof(Rep.rc) + cchDetail + 1);
    373367}
    374368
  • trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp

    r91024 r91040  
    158158    if (RT_SUCCESS(rc))
    159159    {
    160         if (RTStrNCmp(Reply.szOp, "ACK     ", ATSPKT_OPCODE_MAX_LEN) != 0)
    161         {
    162             LogRelFunc(("Received invalid ACK opcode ('%.8s')\n", Reply.szOp));
     160        /* Most likely cases first. */
     161        if (     RTStrNCmp(Reply.szOp, "ACK     ", ATSPKT_OPCODE_MAX_LEN) == 0)
     162        {
     163            /* Nothing to do here. */
     164        }
     165        else if (RTStrNCmp(Reply.szOp, "FAILED  ", ATSPKT_OPCODE_MAX_LEN) == 0)
     166        {
     167            if (Reply.cbPayload)
     168            {
     169                if (Reply.cbPayload == sizeof(ATSPKTREPFAIL))
     170                {
     171                    PATSPKTREPFAIL pRep = (PATSPKTREPFAIL)Reply.pvPayload;
     172                    /** @todo Check NULL termination of pcszMsg? */
     173
     174                    LogRelFunc(("Received error: %s (%Rrc)\n", pRep->ach, pRep->rc));
     175
     176                    rc = pRep->rc; /* Reach error code back to caller. */
     177                }
     178                else
     179                {
     180                    LogRelFunc(("Received invalid failure payload (cb=%zu)\n", Reply.cbPayload));
     181                    rc = VERR_NET_PROTOCOL_ERROR;
     182                }
     183            }
     184        }
     185        else
     186        {
     187            LogRelFunc(("Received invalid opcode ('%.8s')\n", Reply.szOp));
    163188            rc = VERR_NET_PROTOCOL_ERROR;
    164189        }
  • trunk/src/VBox/Devices/Audio/AudioTestServiceProtocol.h

    r89614 r91040  
    189189
    190190/**
     191 * The failure reply structure.
     192 */
     193typedef struct ATSPKTREPFAIL
     194{
     195    /** Embedded packet header. */
     196    ATSPKTHDR   Hdr;
     197    /** Error code (IPRT-style). */
     198    int         rc;
     199    /** Error description. */
     200    char        ach[256];
     201} ATSPKTREPFAIL;
     202/** Pointer to a ATSPKTREPFAIL structure. */
     203typedef ATSPKTREPFAIL *PATSPKTREPFAIL;
     204
     205/**
    191206 * Checks if the two opcodes match.
    192207 *
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