- Timestamp:
- Oct 22, 2021 11:43:28 AM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTestService.cpp
r91996 r91999 819 819 } 820 820 821 /** 822 * Disconnects a client. 823 * 824 * @returns VBox status code. 825 * @param pThis The ATS instance. 826 * @param pInst The ATS client to disconnect. 827 */ 821 828 static int atsClientDisconnect(PATSSERVER pThis, PATSCLIENTINST pInst) 822 829 { … … 824 831 825 832 pInst->enmState = ATSCLIENTSTATE_DESTROYING; 826 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pInst->pTransportClient); 833 834 if ( pThis->pTransportInst 835 && pInst->pTransportClient) 836 { 837 if (pThis->pTransport->pfnNotifyBye) 838 pThis->pTransport->pfnNotifyBye(pThis->pTransportInst, pInst->pTransportClient); 839 840 pThis->pTransport->pfnDisconnect(pThis->pTransportInst, pInst->pTransportClient); 841 /* Pointer is now invalid due to the call above. */ 842 pInst->pTransportClient = NULL; 843 } 827 844 828 845 return VINF_SUCCESS; … … 837 854 static void atsClientFree(PATSCLIENTINST pInst) 838 855 { 856 if (!pInst) 857 return; 858 859 /* Make sure that there is no transport client associated with it anymore. */ 860 AssertReturnVoid(pInst->enmState = ATSCLIENTSTATE_DESTROYING); 861 AssertReturnVoid(pInst->pTransportClient == NULL); 862 839 863 if (pInst->pszHostname) 840 864 RTStrFree(pInst->pszHostname); 841 865 RTMemFree(pInst); 866 pInst = NULL; 842 867 } 843 868 … … 959 984 } 960 985 986 if (papInsts) 987 { 988 for (size_t i = 0; i < cClientsMax; i++) 989 RTMemFree(papInsts[i]); 990 RTMemFree(papInsts); 991 } 992 961 993 return rc; 962 994 } … … 992 1024 993 1025 /* 994 * New connection, create new client structure and spin of 1026 * New connection, create new client structure and spin off 995 1027 * the request handling thread. 996 1028 */ … … 1236 1268 { 1237 1269 RTListNodeRemove(&pIt->NdLst); 1238 1239 RTMemFree(pIt); 1240 pIt = NULL; 1270 atsClientDisconnect(pThis, pIt); 1271 atsClientFree(pIt); 1241 1272 } 1242 1273 -
trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp
r91996 r91999 321 321 if (pClient->pTransport) 322 322 { 323 pClient->pTransport->pfnStop(pClient->pTransportInst);324 323 pClient->pTransport->pfnDestroy(pClient->pTransportInst); 325 pClient->pTransport = NULL;324 pClient->pTransportInst = NULL; /* Invalidate pointer. */ 326 325 } 327 326 } … … 579 578 if (pClient->pTransport->pfnNotifyBye) 580 579 pClient->pTransport->pfnNotifyBye(pClient->pTransportInst, pClient->pTransportClient); 580 581 pClient->pTransport->pfnDisconnect(pClient->pTransportInst, pClient->pTransportClient); 582 pClient->pTransportClient = NULL; 583 584 pClient->pTransport->pfnStop(pClient->pTransportInst); 581 585 } 582 586 -
trunk/src/VBox/Devices/Audio/AudioTestServiceInternal.h
r91996 r91999 131 131 * or \c false if not (regular client). Optional and can be NULL. 132 132 * @param ppClientNew Where to return the allocated client on success. 133 * Must be destroyed with pfnDisconnect() when done. 133 134 */ 134 135 DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, RTMSINTERVAL msTimeout, bool *pfFromServer, PPATSTRANSPORTCLIENT ppClientNew)); 136 137 /** 138 * Disconnects a client and frees up its resources. 139 * 140 * @param pThis The transport instance. 141 * @param pClient Client to disconnect. 142 * The pointer will be invalid after calling. 143 */ 144 DECLR3CALLBACKMEMBER(void, pfnDisconnect, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient)); 135 145 136 146 /** -
trunk/src/VBox/Devices/Audio/AudioTestServiceTcp.cpp
r91996 r91999 124 124 /** 125 125 * Disconnects the current client and frees all stashed data. 126 * 127 * @param pThis Transport instance. 128 * @param pClient Client to disconnect. 126 129 */ 127 130 static void atsTcpDisconnectClient(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 128 131 { 129 132 RT_NOREF(pThis); 133 134 LogRelFlowFunc(("pClient=%RTsock\n", pClient->hTcpClient)); 130 135 131 136 if (pClient->hTcpClient != NIL_RTSOCKET) … … 147 152 pClient->pbTcpStashed = NULL; 148 153 } 154 } 155 156 /** 157 * Free's a client. 158 * 159 * @param pThis Transport instance. 160 * @param pClient Client to free. 161 * The pointer will be invalid after calling. 162 */ 163 static void atsTcpFreeClient(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 164 { 165 if (!pClient) 166 return; 167 168 /* Make sure to disconnect first. */ 169 atsTcpDisconnectClient(pThis, pClient); 170 171 RTMemFree(pClient); 172 pClient = NULL; 149 173 } 150 174 … … 432 456 if (pClient) 433 457 { 434 RTTcpServerDisconnectClient2(pClient->hTcpClient); 435 436 RTMemFree(pClient); 458 atsTcpFreeClient(pThis, pClient); 437 459 pClient = NULL; 438 460 } … … 495 517 while (rc == VERR_INTERRUPTED); 496 518 519 LogRelFlowFunc(("pClient=%RTsock, rc=%Rrc\n", pClient->hTcpClient, rc)); 520 497 521 /* 498 522 * Disconnect the client. 499 523 */ 500 LogRelFlowFunc(("atsTcpDisconnectClient(%RTsock) (RTTcpWrite rc=%Rrc)\n", pClient->hTcpClient, rc));501 524 atsTcpDisconnectClient(pThis, pClient); 502 525 } … … 701 724 702 725 /** 726 * @interface_method_impl{ATSTRANSPORT,pfnDisconnect} 727 */ 728 static DECLCALLBACK(void) atsTcpDisconnect(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 729 { 730 atsTcpFreeClient(pThis, pClient); 731 } 732 733 /** 703 734 * @interface_method_impl{ATSTRANSPORT,pfnPollIn} 704 735 */ … … 769 800 static DECLCALLBACK(int) atsTcpDestroy(PATSTRANSPORTINST pThis) 770 801 { 802 /* Stop things first. */ 803 atsTcpStop(pThis); 804 771 805 /* Finally, clean up the critical section. */ 772 806 if (RTCritSectIsInitialized(&pThis->CritSect)) … … 774 808 775 809 RTMemFree(pThis); 810 pThis = NULL; 776 811 777 812 return VINF_SUCCESS; … … 909 944 /* .pfnStop = */ atsTcpStop, 910 945 /* .pfnWaitForConnect = */ atsTcpWaitForConnect, 946 /* .pfnDisconnect = */ atsTcpDisconnect, 911 947 /* .pfnPollIn = */ atsTcpPollIn, 912 948 /* .pfnPollSetAdd = */ atsTcpPollSetAdd, -
trunk/src/VBox/Devices/Audio/testcase/tstAudioTestService.cpp
r91994 r91999 154 154 RTTEST_CHECK_RC_OK(hTest, rc); 155 155 156 AudioTestSvcClientDestroy(&Client); 157 156 158 rc = AudioTestSvcStop(&Srv); 157 159 RTTEST_CHECK_RC_OK(hTest, rc);
Note:
See TracChangeset
for help on using the changeset viewer.