Changeset 90911 in vbox
- Timestamp:
- Aug 26, 2021 1:27:36 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTestService.cpp
r90905 r90911 118 118 /** Pointer to a ATS client instance. */ 119 119 typedef ATSCLIENTINST *PATSCLIENTINST; 120 121 122 /********************************************************************************************************************************* 123 * Prototypes * 124 *********************************************************************************************************************************/ 125 static int atsClientDisconnect(PATSSERVER pThis, PATSCLIENTINST pInst); 126 127 120 128 121 129 /** … … 483 491 } 484 492 else 485 rc = atsReplyRC(pThis, pInst, pPktHdr, rc, "Shutting down server failed"); 486 487 if (RT_SUCCESS(rc)) 488 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pInst->pTransportClient); 493 rc = atsReplyRC(pThis, pInst, pPktHdr, rc, "Disconnecting client failed"); 489 494 } 490 495 else … … 786 791 * @returns IPRT status code. 787 792 * @param pThis The ATS instance. 788 * @param pInst The ATS client structure sending the request. 789 */ 790 static int atsClientReqProcess(PATSSERVER pThis, PATSCLIENTINST pInst) 793 * @param pInst The ATS client structure sending the request. 794 * @param pfDisconnect Where to return whether to disconnect the client on success or not. 795 */ 796 static int atsClientReqProcess(PATSSERVER pThis, PATSCLIENTINST pInst, bool *pfDisconnect) 791 797 { 792 798 /* … … 805 811 rc = atsDoHowdy(pThis, pInst, pPktHdr); 806 812 else if (atsIsSameOpcode(pPktHdr, ATSPKT_OPCODE_BYE)) 813 { 807 814 rc = atsDoBye(pThis, pInst, pPktHdr); 815 if (RT_SUCCESS(rc)) 816 *pfDisconnect = true; 817 } 808 818 /* Test set handling: */ 809 819 else if (atsIsSameOpcode(pPktHdr, ATSPKT_OPCODE_TESTSET_BEGIN)) … … 827 837 } 828 838 829 /** 830 * Destroys a client instance. 839 static int atsClientDisconnect(PATSSERVER pThis, PATSCLIENTINST pInst) 840 { 841 AssertReturn(pInst->enmState != ATSCLIENTSTATE_DESTROYING, VERR_WRONG_ORDER); 842 843 pInst->enmState = ATSCLIENTSTATE_DESTROYING; 844 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pInst->pTransportClient); 845 846 return VINF_SUCCESS; 847 } 848 849 /** 850 * Free's (destroys) a client instance. 831 851 * 832 852 * @returns nothing. 833 853 * @param pInst The opaque ATS instance structure. 834 854 */ 835 static void atsClient Destroy(PATSCLIENTINST pInst)855 static void atsClientFree(PATSCLIENTINST pInst) 836 856 { 837 857 if (pInst->pszHostname) … … 911 931 else 912 932 { 913 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pIt->pTransportClient); 914 atsClientDestroy(pIt); 933 atsClientDisconnect(pThis, pIt); 934 atsClientFree(pIt); 935 pIt = NULL; 915 936 } 916 937 } 917 938 else 918 939 { 919 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pIt->pTransportClient); 920 atsClientDestroy(pIt); 940 atsClientDisconnect(pThis, pIt); 941 atsClientFree(pIt); 942 pIt = NULL; 921 943 } 922 944 } … … 925 947 else 926 948 { 949 bool fDisconnect = false; 950 927 951 /* Client sends a request, pick the right client and process it. */ 928 952 PATSCLIENTINST pInst = papInsts[uId - 1]; 929 953 AssertPtr(pInst); 930 954 if (fEvts & RTPOLL_EVT_READ) 931 rc = atsClientReqProcess(pThis, pInst );955 rc = atsClientReqProcess(pThis, pInst, &fDisconnect); 932 956 933 957 if ( (fEvts & RTPOLL_EVT_ERROR) 934 || RT_FAILURE(rc)) 958 || RT_FAILURE(rc) 959 || fDisconnect) 935 960 { 936 961 /* Close connection and remove client from array. */ 937 rc = pThis->pTransport->pfnPollSetRemove(pThis->pTransportInst, pThis->hPollSet, pInst->pTransportClient, uId); 938 AssertRC(rc); 939 940 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pInst->pTransportClient); 941 pInst->pTransportClient = NULL; 962 int rc2 = pThis->pTransport->pfnPollSetRemove(pThis->pTransportInst, pThis->hPollSet, pInst->pTransportClient, uId); 963 AssertRC(rc2); 964 965 atsClientDisconnect(pThis, pInst); 966 atsClientFree(pInst); 967 pInst = NULL; 968 942 969 papInsts[uId - 1] = NULL; 970 Assert(cClientsCur); 943 971 cClientsCur--; 944 atsClientDestroy(pInst);945 972 } 946 973 }
Note:
See TracChangeset
for help on using the changeset viewer.