- Timestamp:
- Aug 30, 2021 7:44:20 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTestServiceTcp.cpp
r90962 r91012 131 131 if (pClient->hTcpClient != NIL_RTSOCKET) 132 132 { 133 LogRelFlowFunc(("Disconnecting client %RTsock\n", pClient->hTcpClient)); 134 133 135 int rc; 134 136 if (pClient->fFromServer) … … 150 152 * Sets the current client socket in a safe manner. 151 153 * 152 * @returns NIL_RTSOCKET if consumed, other 154 * @returns NIL_RTSOCKET if consumed, otherwise hTcpClient. 153 155 * @param pThis Transport instance. 154 156 * @param pClient Client to set the socket for. … … 163 165 && !pThis->fStopConnecting) 164 166 { 165 Log Func(("New client connected\n"));167 LogRelFlowFunc(("New client %RTsock connected (fFromServer=%RTbool)\n", hTcpClient, fFromServer)); 166 168 167 169 pClient->fFromServer = fFromServer; … … 206 208 /** @todo Implement cancellation support for using pConnCtx->msTimeout. */ 207 209 210 LogRelFlowFuncEnter(); 211 208 212 RTSOCKET hTcpClient; 209 213 int rc = RTTcpServerListen2(pThis->pTcpServer, &hTcpClient); … … 214 218 } 215 219 220 LogRelFlowFuncLeaveRC(rc); 216 221 return rc; 217 222 } … … 233 238 uint64_t msStartTs = RTTimeMilliTS(); 234 239 240 LogRelFlowFuncEnter(); 241 235 242 for (;;) 236 243 { … … 259 266 && RTTimeMilliTS() - msStartTs >= pConnCtx->msTimeout) 260 267 { 268 LogRelFlowFunc(("Timed out (%RU32ms)\n", pConnCtx->msTimeout)); 261 269 return VERR_TIMEOUT; 262 270 } … … 265 273 RTThreadUserWait(hSelf, 1536); 266 274 } 275 276 LogRelFlowFuncLeave(); 267 277 return VINF_SUCCESS; 268 278 } … … 279 289 int rcRet = VINF_SUCCESS; 280 290 291 LogRelFlowFuncEnter(); 292 281 293 if (pThis->hThreadConnect != NIL_RTTHREAD) 282 294 { … … 301 313 } 302 314 } 315 316 LogRelFlowFuncLeaveRC(rcRet); 303 317 return rcRet; 304 318 } … … 314 328 int rc; 315 329 316 Log Func(("msTimeout=%RU32, enmConnMode=%#x\n", msTimeout, pThis->enmConnMode));330 LogRelFlowFunc(("msTimeout=%RU32, enmConnMode=%#x\n", msTimeout, pThis->enmConnMode)); 317 331 318 332 uint64_t msStartTs = RTTimeMilliTS(); … … 324 338 pClient->fFromServer = true; 325 339 rc = RTTcpServerListen2(pThis->pTcpServer, &pClient->hTcpClient); 326 Log Func(("RTTcpServerListen2 -> %Rrc\n", rc));340 LogRelFlowFunc(("RTTcpServerListen2 -> %Rrc\n", rc)); 327 341 } 328 342 else if (pThis->enmConnMode == ATSCONNMODE_CLIENT) … … 331 345 for (;;) 332 346 { 333 Log 2Func(("Calling RTTcpClientConnect(%s, %u,)...\n", pThis->szConnectAddr, pThis->uConnectPort));347 LogRelFlowFunc(("Calling RTTcpClientConnect(%s, %u,)...\n", pThis->szConnectAddr, pThis->uConnectPort)); 334 348 rc = RTTcpClientConnect(pThis->szConnectAddr, pThis->uConnectPort, &pClient->hTcpClient); 335 Log Func(("RTTcpClientConnect -> %Rrc\n", rc));349 LogRelFlowFunc(("RTTcpClientConnect -> %Rrc\n", rc)); 336 350 if (RT_SUCCESS(rc) || atsTcpIsFatalClientConnectStatus(rc)) 337 351 break; … … 422 436 } 423 437 438 if (RT_FAILURE(rc)) 439 LogRelFunc(("Failed with %Rrc\n", rc)); 440 424 441 return rc; 425 442 } … … 430 447 static DECLCALLBACK(void) atsTcpNotifyReboot(PATSTRANSPORTINST pThis) 431 448 { 432 Log Func(("RTTcpServerDestroy(%p)\n", pThis->pTcpServer));449 LogRelFlowFuncEnter(); 433 450 if (pThis->pTcpServer) 434 451 { 435 452 int rc = RTTcpServerDestroy(pThis->pTcpServer); 436 453 if (RT_FAILURE(rc)) 437 LogRel (("RTTcpServerDestroy failed in atsTcpNotifyReboot:%Rrc", rc));454 LogRelFunc(("RTTcpServerDestroy failed, rc=%Rrc", rc)); 438 455 pThis->pTcpServer = NULL; 439 456 } 457 LogRelFlowFuncLeave(); 440 458 } 441 459 … … 475 493 * Disconnect the client. 476 494 */ 477 Log Func(("atsTcpDisconnectClient(%RTsock) (RTTcpWrite rc=%Rrc)\n", pClient->hTcpClient, rc));495 LogRelFlowFunc(("atsTcpDisconnectClient(%RTsock) (RTTcpWrite rc=%Rrc)\n", pClient->hTcpClient, rc)); 478 496 atsTcpDisconnectClient(pThis, pClient); 479 497 } … … 493 511 Log3Func(("%RU32 -> %zu\n", pPktHdr->cb, cbToSend)); 494 512 495 Log 3Func(("Header:\n"496 "%.*Rhxd\n", RT_MIN(sizeof(ATSPKTHDR), cbToSend), pPktHdr));513 LogRelFlowFunc(("Header:\n" 514 "%.*Rhxd\n", RT_MIN(sizeof(ATSPKTHDR), cbToSend), pPktHdr)); 497 515 498 516 if (cbToSend > sizeof(ATSPKTHDR)) 499 Log 3Func(("Payload:\n"500 "%.*Rhxd\n",501 RT_MIN(64, cbToSend - sizeof(ATSPKTHDR)), (uint8_t *)pPktHdr + sizeof(ATSPKTHDR)));517 LogRelFlowFunc(("Payload:\n" 518 "%.*Rhxd\n", 519 RT_MIN(64, cbToSend - sizeof(ATSPKTHDR)), (uint8_t *)pPktHdr + sizeof(ATSPKTHDR))); 502 520 503 521 int rc = RTTcpWrite(pClient->hTcpClient, pPktHdr, cbToSend); … … 506 524 { 507 525 /* assume fatal connection error. */ 508 Log Func(("RTTcpWrite -> %Rrc -> atsTcpDisconnectClient(%RTsock)\n", rc, pClient->hTcpClient));526 LogRelFunc(("RTTcpWrite -> %Rrc -> atsTcpDisconnectClient(%RTsock)\n", rc, pClient->hTcpClient)); 509 527 atsTcpDisconnectClient(pThis, pClient); 510 528 } … … 561 579 if (cbRead == 0) 562 580 { 563 Log Func(("RTTcpRead -> %Rrc / cbRead=0 -> VERR_NET_NOT_CONNECTED (#1)\n", rc));581 LogRelFunc(("RTTcpRead -> %Rrc / cbRead=0 -> VERR_NET_NOT_CONNECTED (#1)\n", rc)); 564 582 rc = VERR_NET_NOT_CONNECTED; 565 583 break; … … 601 619 if (cbRead == 0) 602 620 { 603 Log Func(("RTTcpRead -> %Rrc / cbRead=0 -> VERR_NET_NOT_CONNECTED (#2)\n", rc));621 LogRelFunc(("RTTcpRead -> %Rrc / cbRead=0 -> VERR_NET_NOT_CONNECTED (#2)\n", rc)); 604 622 rc = VERR_NET_NOT_CONNECTED; 605 623 break; … … 609 627 } 610 628 611 Log 3Func(("Header:\n"612 "%.*Rhxd\n", sizeof(ATSPKTHDR), pbData));629 LogRelFlowFunc(("Header:\n" 630 "%.*Rhxd\n", sizeof(ATSPKTHDR), pbData)); 613 631 614 632 if ( RT_SUCCESS(rc) 615 633 && cbData > sizeof(ATSPKTHDR)) 616 Log 3Func(("Payload:\n"617 "%.*Rhxd\n", RT_MIN(64, cbData - sizeof(ATSPKTHDR)), (uint8_t *)pbData + sizeof(ATSPKTHDR)));634 LogRelFlowFunc(("Payload:\n" 635 "%.*Rhxd\n", RT_MIN(64, cbData - sizeof(ATSPKTHDR)), (uint8_t *)pbData + sizeof(ATSPKTHDR))); 618 636 } 619 637 } … … 643 661 644 662 /* assume fatal connection error. */ 645 Log Func(("RTTcpRead -> %Rrc -> atsTcpDisconnectClient(%RTsock)\n", rc, pClient->hTcpClient));663 LogRelFunc(("RTTcpRead -> %Rrc -> atsTcpDisconnectClient(%RTsock)\n", rc, pClient->hTcpClient)); 646 664 atsTcpDisconnectClient(pThis, pClient); 647 665 } … … 684 702 static DECLCALLBACK(void) atsTcpTerm(PATSTRANSPORTINST pThis) 685 703 { 704 LogRelFlowFuncEnter(); 705 686 706 /* Signal thread */ 687 707 if (RTCritSectIsInitialized(&pThis->CritSect)) … … 701 721 if (pThis->pTcpServer) 702 722 { 703 Log Func(("Destroying server...\n"));723 LogRelFlowFunc(("Destroying server...\n")); 704 724 int rc = RTTcpServerDestroy(pThis->pTcpServer); 705 725 if (RT_FAILURE(rc)) 706 LogRel (("RTTcpServerDestroy failed in atsTcpTerm:%Rrc", rc));726 LogRelFunc(("RTTcpServerDestroy failed with %Rrc", rc)); 707 727 pThis->pTcpServer = NULL; 708 728 } … … 711 731 atsTcpConnectWaitOnThreads(pThis, 15000); 712 732 713 Log Func(("Done\n"));733 LogRelFlowFuncLeave(); 714 734 } 715 735 … … 759 779 if (rc == VERR_NET_DOWN) 760 780 { 761 LogRel 2(("RTTcpServerCreateEx(%s, %u,) failed: %Rrc, retrying for 20 seconds...\n",762 pThis->szBindAddr[0] ? pThis->szBindAddr : NULL, pThis->uBindPort, rc));781 LogRelFunc(("RTTcpServerCreateEx(%s, %u,) failed: %Rrc, retrying for 20 seconds...\n", 782 pThis->szBindAddr[0] ? pThis->szBindAddr : NULL, pThis->uBindPort, rc)); 763 783 uint64_t StartMs = RTTimeMilliTS(); 764 784 do … … 769 789 && RTTimeMilliTS() - StartMs < 20000); 770 790 if (RT_SUCCESS(rc)) 771 LogRel 2(("RTTcpServerCreateEx succceeded\n"));791 LogRelFunc(("RTTcpServerCreateEx succceeded\n")); 772 792 } 773 793 774 794 if (RT_FAILURE(rc)) 775 795 { 776 LogRel (("RTTcpServerCreateEx(%s, %u,) failed: %Rrc\n",777 pThis->szBindAddr[0] ? pThis->szBindAddr : NULL, pThis->uBindPort, rc));796 LogRelFunc(("RTTcpServerCreateEx(%s, %u,) failed: %Rrc\n", 797 pThis->szBindAddr[0] ? pThis->szBindAddr : NULL, pThis->uBindPort, rc)); 778 798 } 779 799 }
Note:
See TracChangeset
for help on using the changeset viewer.