Changeset 65854 in vbox for trunk/src/VBox/Main/src-server/generic/USBProxyBackendUsbIp.cpp
- Timestamp:
- Feb 23, 2017 11:48:49 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note:
See TracChangeset
for help on using the changeset viewer.