Changeset 60785 in vbox for trunk/src/VBox/Main/src-server/generic
- Timestamp:
- May 2, 2016 11:58:20 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106983
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/generic/USBProxyBackendUsbIp.cpp
r60755 r60785 499 499 rc = VERR_NET_SHUTDOWN; 500 500 501 if (RT_SUCCESS(rc)) 501 /* 502 * If we are in the none state again we received the previous request 503 * and have a new device list to compare the old against. 504 */ 505 if (m->enmRecvState == kUsbIpRecvState_None) 502 506 { 503 /* 504 * If we are in the none state again we received the previous request 505 * and have a new device list to compare the old against. 506 */ 507 if (m->enmRecvState == kUsbIpRecvState_None) 508 { 509 if (hasDevListChanged(m->pHead)) 510 fDeviceListChangedOrWokenUp = true; 511 512 /* Update to the new list in any case now that we have it anyway. */ 513 RTSemFastMutexRequest(m->hMtxDevices); 514 freeDeviceList(m->pUsbDevicesCur); 515 m->cUsbDevicesCur = m->cDevicesCur; 516 m->pUsbDevicesCur = m->pHead; 517 RTSemFastMutexRelease(m->hMtxDevices); 518 519 m->pHead = NULL; 520 resetRecvState(); 521 } 507 if (hasDevListChanged(m->pHead)) 508 fDeviceListChangedOrWokenUp = true; 509 510 /* Update to the new list in any case now that we have it anyway. */ 511 RTSemFastMutexRequest(m->hMtxDevices); 512 freeDeviceList(m->pUsbDevicesCur); 513 m->cUsbDevicesCur = m->cDevicesCur; 514 m->pUsbDevicesCur = m->pHead; 515 RTSemFastMutexRelease(m->hMtxDevices); 516 517 m->pHead = NULL; 518 resetRecvState(); 522 519 } 523 else if (rc == VERR_NET_SHUTDOWN || rc == VERR_BROKEN_PIPE || rc == VERR_NET_CONNECTION_RESET_BY_PEER) 520 521 /* Current USB/IP server closes the connection after each request, don't abort but try again. */ 522 if (rc == VERR_NET_SHUTDOWN || rc == VERR_BROKEN_PIPE || rc == VERR_NET_CONNECTION_RESET_BY_PEER) 524 523 { 525 524 Log(("USB/IP: Lost connection to host \"%s\", trying to reconnect...\n", m->pszHost)); … … 573 572 PUSBDEVICE pFirst = NULL; 574 573 PUSBDEVICE *ppNext = &pFirst; 574 575 LogFlowThisFunc(("\n")); 575 576 576 577 /* Create a deep copy of the device list. */ … … 614 615 RTSemFastMutexRelease(m->hMtxDevices); 615 616 617 LogFlowThisFunc(("returning %#p\n", pFirst)); 616 618 return pFirst; 617 619 } … … 641 643 void USBProxyBackendUsbIp::resetRecvState() 642 644 { 645 LogFlowFunc(("\n")); 643 646 freeDeviceList(m->pHead); 644 647 m->pHead = NULL; … … 649 652 m->pbRecvBuf = &m->Scratch.abRecv[0]; 650 653 m->cDevicesLeft = 0; 654 LogFlowFunc(("\n")); 651 655 } 652 656 … … 658 662 void USBProxyBackendUsbIp::disconnect() 659 663 { 664 LogFlowFunc(("\n")); 665 660 666 if (m->hSocket != NIL_RTSOCKET) 661 667 { … … 668 674 669 675 resetRecvState(); 676 LogFlowFunc(("returns\n")); 670 677 } 671 678 … … 677 684 int USBProxyBackendUsbIp::reconnect() 678 685 { 686 LogFlowFunc(("\n")); 687 679 688 /* Make sure we are disconnected. */ 680 689 disconnect(); … … 699 708 } 700 709 710 LogFlowFunc(("returns rc=%Rrc\n", rc)); 701 711 return rc; 702 712 } … … 710 720 { 711 721 int rc = VINF_SUCCESS; 722 723 LogFlowFunc(("\n")); 712 724 713 725 /* … … 731 743 } 732 744 745 LogFlowFunc(("returns rc=%Rrc\n", rc)); 733 746 return rc; 734 747 } … … 742 755 void USBProxyBackendUsbIp::advanceState(USBIPRECVSTATE enmRecvState) 743 756 { 757 LogFlowFunc(("enmRecvState=%u\n", enmRecvState)); 758 744 759 switch (enmRecvState) 745 760 { … … 770 785 771 786 m->enmRecvState = enmRecvState; 787 LogFlowFunc(("returns\n")); 772 788 } 773 789 … … 783 799 size_t cbRecvd = 0; 784 800 801 LogFlowFunc(("\n")); 802 785 803 do 786 804 { 787 805 rc = RTTcpReadNB(m->hSocket, m->pbRecvBuf, m->cbResidualRecv, &cbRecvd); 806 807 LogFlowFunc(("RTTcpReadNB(%#p, %#p, %zu, %zu) -> %Rrc\n", 808 m->hSocket, m->pbRecvBuf, m->cbResidualRecv, cbRecvd)); 809 788 810 if (RT_SUCCESS(rc)) 789 811 { … … 791 813 m->pbRecvBuf += cbRecvd; 792 814 /* In case we received everything for the current state process the data. */ 793 if (!m->cbResidualRecv) 815 if ( !m->cbResidualRecv 816 && cbRecvd > 0) 794 817 { 795 818 rc = processData(); … … 801 824 } while (RT_SUCCESS(rc) && cbRecvd > 0); 802 825 826 LogFlowFunc(("returns rc=%Rrc\n", rc)); 803 827 return rc; 804 828 } … … 899 923 int USBProxyBackendUsbIp::addDeviceToList(PUsbIpExportedDevice pDev) 900 924 { 925 int rc = VINF_SUCCESS; 901 926 PUSBDEVICE pNew = (PUSBDEVICE)RTMemAllocZ(sizeof(USBDEVICE)); 902 927 if (!pNew) … … 910 935 /* Make sure the Bus id is 0 terminated. */ 911 936 pDev->szBusId[31] = '\0'; 912 int rc = RTStrAPrintf((char **)&pNew->pszAddress,"usbip://%s:%u:%s", m->pszHost, m->uPort, &pDev->szBusId[0]);913 if (RT_ SUCCESS(rc))937 pNew->pszAddress = RTStrAPrintf2("usbip://%s:%u:%s", m->pszHost, m->uPort, &pDev->szBusId[0]); 938 if (RT_LIKELY(pNew->pszAddress)) 914 939 { 915 940 pNew->idVendor = pDev->u16VendorId; … … 966 991 m->cDevicesCur++; 967 992 } 993 else 994 rc = VERR_NO_STR_MEMORY; 968 995 969 996 if (RT_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.