VirtualBox

Ignore:
Timestamp:
Feb 23, 2017 11:48:49 AM (8 years ago)
Author:
vboxsync
Message:

Main/USBProxyBackendUsbIp: Don't prevent VBoxSVC from starting when the server is not reachable, just try to reconnect every 3 seconds. Smaller other fixes for stale USB device lists when the server is not reachable and a fix for saving the same USB source multiple times

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/generic/USBProxyBackendUsbIp.cpp

    r65542 r65854  
    280280 * @returns S_OK on success and non-fatal failures, some COM error otherwise.
    281281 */
    282 int USBProxyBackendUsbIp::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress)
     282int USBProxyBackendUsbIp::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId,
     283                               const com::Utf8Str &strAddress, bool fLoadingSettings)
    283284{
    284285    int rc = VINF_SUCCESS;
    285286
    286     USBProxyBackend::init(aUsbProxyService, strId, strAddress);
     287    USBProxyBackend::init(pUsbProxyService, strId, strAddress, fLoadingSettings);
    287288
    288289    unconst(m_strBackend) = Utf8Str("USBIP");
     
    318319                if (RT_SUCCESS(rc))
    319320                {
    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                     */
    321330                    rc = reconnect();
    322                     if (RT_SUCCESS(rc))
     331                    if (RT_SUCCESS(rc) || fLoadingSettings)
    323332                        rc = start(); /* Start service thread. */
    324333                }
     
    448457    /* Try to reconnect once when we enter if we lost the connection earlier. */
    449458    if (m->hSocket == NIL_RTSOCKET)
    450         rc = reconnect();
     459        reconnect();
    451460
    452461    /* Query a new device list upon entering. */
    453     if (   RT_SUCCESS(rc)
     462    if (   m->hSocket != NIL_RTSOCKET
    454463        && m->enmRecvState == kUsbIpRecvState_None)
    455464    {
     
    474483        uint32_t fEventsRecv = 0;
    475484
    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. */
    477486        if (m->hSocket == NIL_RTSOCKET || m->enmRecvState == kUsbIpRecvState_None)
    478             msWait = RT_MIN(1000, aMillies);
     487            msWait = RT_MIN(3000, aMillies);
    479488
    480489        rc = RTPoll(m->hPollSet, msWait, &fEventsRecv, &uIdReady);
     
    549558                             || rc == VERR_NET_CONNECTION_RESET_BY_PEER
    550559                             || 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);
    551571                        rc = VINF_SUCCESS;
     572                    }
    552573                }
    553574            }
     
    815836                     m->hSocket, m->pbRecvBuf, m->cbResidualRecv, cbRecvd, rc));
    816837
    817         if (rc == VINF_SUCCESS)
    818         {
    819             Assert(cbRecvd > 0);
     838        if (   rc == VINF_SUCCESS
     839            && cbRecvd > 0)
     840        {
    820841            m->cbResidualRecv -= cbRecvd;
    821842            m->pbRecvBuf      += cbRecvd;
    822843            /* In case we received everything for the current state process the data. */
    823             if (   !m->cbResidualRecv
    824                 && cbRecvd > 0)
     844            if (!m->cbResidualRecv)
    825845            {
    826846                rc = processData();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette