Changeset 65854 in vbox for trunk/src/VBox/Main
- Timestamp:
- Feb 23, 2017 11:48:49 AM (8 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/USBProxyBackend.h
r65088 r65854 48 48 49 49 // public initializer/uninitializer for internal purposes only 50 virtual int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 50 virtual int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 51 const com::Utf8Str &strAddress, bool fLoadingSettings); 51 52 virtual void uninit(); 52 53 … … 147 148 DECLARE_EMPTY_CTOR_DTOR(USBProxyBackendDarwin) 148 149 149 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 150 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 151 const com::Utf8Str &strAddress, bool fLoadingSettings); 150 152 void uninit(); 151 153 … … 196 198 DECLARE_EMPTY_CTOR_DTOR(USBProxyBackendLinux) 197 199 198 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 200 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 201 const com::Utf8Str &strAddress, bool fLoadingSettings); 199 202 void uninit(); 200 203 … … 287 290 DECLARE_EMPTY_CTOR_DTOR(USBProxyBackendSolaris) 288 291 289 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 292 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 293 const com::Utf8Str &strAddress, bool fLoadingSettings); 290 294 void uninit(); 291 295 … … 322 326 DECLARE_EMPTY_CTOR_DTOR(USBProxyBackendWindows) 323 327 324 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 328 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 329 const com::Utf8Str &strAddress, bool fLoadingSettings); 325 330 void uninit(); 326 331 … … 353 358 DECLARE_EMPTY_CTOR_DTOR(USBProxyBackendFreeBSD) 354 359 355 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 360 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 361 const com::Utf8Str &strAddress, bool fLoadingSettings); 356 362 void uninit(); 357 363 … … 404 410 DECLARE_EMPTY_CTOR_DTOR(USBProxyBackendUsbIp) 405 411 406 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress); 412 int init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 413 const com::Utf8Str &strAddress, bool fLoadingSettings); 407 414 void uninit(); 408 415 -
trunk/src/VBox/Main/include/USBProxyService.h
r62485 r65854 106 106 HRESULT createUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, 107 107 const com::Utf8Str &aAddress, const std::vector<com::Utf8Str> &aPropertyNames, 108 const std::vector<com::Utf8Str> &aPropertyValues );108 const std::vector<com::Utf8Str> &aPropertyValues, bool fLoadingSettings); 109 109 110 110 private: -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r65120 r65854 1784 1784 1785 1785 data.llUSBDeviceFilters.clear(); 1786 data.llUSBDeviceSources.clear(); 1786 1787 1787 1788 for (USBDeviceFilterList::const_iterator it = m->llUSBDeviceFilters.begin(); -
trunk/src/VBox/Main/src-server/USBProxyBackend.cpp
r65529 r65854 66 66 * Stub needed as long as the class isn't virtual 67 67 */ 68 int USBProxyBackend::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 69 { 68 int USBProxyBackend::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 69 const com::Utf8Str &strAddress, bool fLoadingSettings) 70 { 71 RT_NOREF1(fLoadingSettings); 72 70 73 m_pUsbProxyService = pUsbProxyService; 71 74 mThread = NIL_RTTHREAD; -
trunk/src/VBox/Main/src-server/USBProxyService.cpp
r65457 r65854 81 81 # endif 82 82 UsbProxyBackendHost.createObject(); 83 int vrc = UsbProxyBackendHost->init(this, Utf8Str("host"), Utf8Str("") );83 int vrc = UsbProxyBackendHost->init(this, Utf8Str("host"), Utf8Str(""), false /* fLoadingSettings */); 84 84 if (RT_FAILURE(vrc)) 85 85 { … … 212 212 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 213 213 214 HRESULT hrc = createUSBDeviceSource(aBackend, aId, aAddress, aPropertyNames, aPropertyValues); 214 HRESULT hrc = createUSBDeviceSource(aBackend, aId, aAddress, aPropertyNames, 215 aPropertyValues, false /* fLoadingSettings */); 215 216 if (SUCCEEDED(hrc)) 216 217 { … … 500 501 std::vector<com::Utf8Str> vecPropNames, vecPropValues; 501 502 const settings::USBDeviceSource &src = *it; 502 hrc = createUSBDeviceSource(src.strBackend, src.strName, src.strAddress, vecPropNames, vecPropValues); 503 hrc = createUSBDeviceSource(src.strBackend, src.strName, src.strAddress, 504 vecPropNames, vecPropValues, true /* fLoadingSettings */); 503 505 } 504 506 … … 892 894 * @param aPropertyNames Vector of optional property keys the backend supports. 893 895 * @param aPropertyValues Vector of optional property values the backend supports. 896 * @param fLoadingSettings Flag whether the USB device source is created while the 897 * settings are loaded or through the Main API. 894 898 */ 895 899 HRESULT USBProxyService::createUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, 896 900 const com::Utf8Str &aAddress, const std::vector<com::Utf8Str> &aPropertyNames, 897 const std::vector<com::Utf8Str> &aPropertyValues) 901 const std::vector<com::Utf8Str> &aPropertyValues, 902 bool fLoadingSettings) 898 903 { 899 904 HRESULT hrc = S_OK; … … 923 928 924 929 UsbProxyBackend.createObject(); 925 int vrc = UsbProxyBackend->init(this, aId, aAddress );930 int vrc = UsbProxyBackend->init(this, aId, aAddress, fLoadingSettings); 926 931 if (RT_FAILURE(vrc)) 927 932 hrc = setError(E_FAIL, -
trunk/src/VBox/Main/src-server/darwin/USBProxyBackendDarwin.cpp
r62485 r65854 53 53 * @returns VBox status code. 54 54 */ 55 int USBProxyBackendDarwin::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 56 { 57 USBProxyBackend::init(pUsbProxyService, strId, strAddress); 55 int USBProxyBackendDarwin::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 56 const com::Utf8Str &strAddress, bool fLoadingSettings) 57 { 58 USBProxyBackend::init(pUsbProxyService, strId, strAddress, fLoadingSettings); 58 59 59 60 unconst(m_strBackend) = Utf8Str("host"); -
trunk/src/VBox/Main/src-server/freebsd/USBProxyBackendFreeBSD.cpp
r65539 r65854 76 76 * @returns S_OK on success and non-fatal failures, some COM error otherwise. 77 77 */ 78 int USBProxyBackendFreeBSD::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 79 { 80 USBProxyBackend::init(pUsbProxyService, strId, strAddress); 78 int USBProxyBackendFreeBSD::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 79 const com::Utf8Str &strAddress, bool fLoadingSettings) 80 { 81 USBProxyBackend::init(pUsbProxyService, strId, strAddress, fLoadingSettings); 81 82 82 83 unconst(m_strBackend) = Utf8Str("host"); -
trunk/src/VBox/Main/src-server/generic/USBProxyBackendUsbIp.cpp
r65542 r65854 280 280 * @returns S_OK on success and non-fatal failures, some COM error otherwise. 281 281 */ 282 int USBProxyBackendUsbIp::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 282 int USBProxyBackendUsbIp::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 283 const com::Utf8Str &strAddress, bool fLoadingSettings) 283 284 { 284 285 int rc = VINF_SUCCESS; 285 286 286 USBProxyBackend::init( aUsbProxyService, strId, strAddress);287 USBProxyBackend::init(pUsbProxyService, strId, strAddress, fLoadingSettings); 287 288 288 289 unconst(m_strBackend) = Utf8Str("USBIP"); … … 318 319 if (RT_SUCCESS(rc)) 319 320 { 320 /* Connect to the USB/IP host. */ 321 /* 322 * Connect to the USB/IP host. Be more graceful to connection errors 323 * if we are instantiated while the settings are loaded to let 324 * VBoxSVC start. 325 * 326 * The worker thread keeps trying to connect every few seconds until 327 * either the USB source is removed by the user or the USB server is 328 * reachable. 329 */ 321 330 rc = reconnect(); 322 if (RT_SUCCESS(rc) )331 if (RT_SUCCESS(rc) || fLoadingSettings) 323 332 rc = start(); /* Start service thread. */ 324 333 } … … 448 457 /* Try to reconnect once when we enter if we lost the connection earlier. */ 449 458 if (m->hSocket == NIL_RTSOCKET) 450 r c = reconnect();459 reconnect(); 451 460 452 461 /* Query a new device list upon entering. */ 453 if ( RT_SUCCESS(rc)462 if ( m->hSocket != NIL_RTSOCKET 454 463 && m->enmRecvState == kUsbIpRecvState_None) 455 464 { … … 474 483 uint32_t fEventsRecv = 0; 475 484 476 /* Limit the waiting time to 1sec so we can either reconnect or get a new device list. */485 /* Limit the waiting time to 3sec so we can either reconnect or get a new device list. */ 477 486 if (m->hSocket == NIL_RTSOCKET || m->enmRecvState == kUsbIpRecvState_None) 478 msWait = RT_MIN( 1000, aMillies);487 msWait = RT_MIN(3000, aMillies); 479 488 480 489 rc = RTPoll(m->hPollSet, msWait, &fEventsRecv, &uIdReady); … … 549 558 || rc == VERR_NET_CONNECTION_RESET_BY_PEER 550 559 || rc == VERR_NET_CONNECTION_REFUSED) 560 { 561 /* Make sure the device list is clear. */ 562 RTSemFastMutexRequest(m->hMtxDevices); 563 if (m->pUsbDevicesCur) 564 { 565 freeDeviceList(m->pUsbDevicesCur); 566 fDeviceListChangedOrWokenUp = true; 567 m->cUsbDevicesCur = 0; 568 m->pUsbDevicesCur = NULL; 569 } 570 RTSemFastMutexRelease(m->hMtxDevices); 551 571 rc = VINF_SUCCESS; 572 } 552 573 } 553 574 } … … 815 836 m->hSocket, m->pbRecvBuf, m->cbResidualRecv, cbRecvd, rc)); 816 837 817 if ( rc == VINF_SUCCESS)818 {819 Assert(cbRecvd > 0);838 if ( rc == VINF_SUCCESS 839 && cbRecvd > 0) 840 { 820 841 m->cbResidualRecv -= cbRecvd; 821 842 m->pbRecvBuf += cbRecvd; 822 843 /* In case we received everything for the current state process the data. */ 823 if ( !m->cbResidualRecv 824 && cbRecvd > 0) 844 if (!m->cbResidualRecv) 825 845 { 826 846 rc = processData(); -
trunk/src/VBox/Main/src-server/linux/USBProxyBackendLinux.cpp
r62485 r65854 80 80 * @returns VBox status code. 81 81 */ 82 int USBProxyBackendLinux::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 83 { 84 USBProxyBackend::init(pUsbProxyService, strId, strAddress); 82 int USBProxyBackendLinux::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, 83 const com::Utf8Str &strAddress, bool fLoadingSettings) 84 { 85 USBProxyBackend::init(pUsbProxyService, strId, strAddress, fLoadingSettings); 85 86 86 87 unconst(m_strBackend) = Utf8Str("host"); -
trunk/src/VBox/Main/src-server/solaris/USBProxyBackendSolaris.cpp
r63542 r65854 70 70 * @returns VBox status code. 71 71 */ 72 int USBProxyBackendSolaris::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 73 { 74 USBProxyBackend::init(aUsbProxyService, strId, strAddress); 72 int USBProxyBackendSolaris::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, 73 const com::Utf8Str &strAddress, bool fLoadingSettings) 74 { 75 USBProxyBackend::init(aUsbProxyService, strId, strAddress, fLoadingSettings); 75 76 76 77 unconst(m_strBackend) = Utf8Str("host"); -
trunk/src/VBox/Main/src-server/win/USBProxyBackendWindows.cpp
r62485 r65854 53 53 * @returns S_OK on success and non-fatal failures, some COM error otherwise. 54 54 */ 55 int USBProxyBackendWindows::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress) 56 { 57 USBProxyBackend::init(aUsbProxyService, strId, strAddress); 55 int USBProxyBackendWindows::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, 56 const com::Utf8Str &strAddress, bool fLoadingSettings) 57 { 58 USBProxyBackend::init(aUsbProxyService, strId, strAddress, fLoadingSettings); 58 59 59 60 unconst(m_strBackend) = Utf8Str("host");
Note:
See TracChangeset
for help on using the changeset viewer.