VirtualBox

Changeset 65883 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Feb 25, 2017 7:32:34 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
113666
Message:

Main/USBProxyBackendUsbIp: Follow up fix, only clear the device list if a connection to the server couldn't be established for some time. Increase the timespan between tries from 1 second to 3 seconds to avoid unnecessary network traffic

File:
1 edited

Legend:

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

    r65875 r65883  
    55
    66/*
    7  * Copyright (C) 2015-2016 Oracle Corporation
     7 * Copyright (C) 2015-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3939#include <iprt/asm.h>
    4040#include <iprt/cdefs.h>
     41#include <iprt/time.h>
    4142
    4243/** The USB/IP default port to connect to. */
     
    244245    /** Current amount of devices in the list. */
    245246    uint32_t                 cDevicesCur;
     247    /** Timestamp of the last time we successfully connected. */
     248    uint64_t                 tsConnectSuccessLast;
    246249};
    247250
     
    290293
    291294    m = new Data;
     295
     296    m->tsConnectSuccessLast = 0;
    292297
    293298    /* Split address into hostname and port. */
     
    489494        /* Limit the waiting time to 3sec so we can either reconnect or get a new device list. */
    490495        if (m->hSocket == NIL_RTSOCKET || m->enmRecvState == kUsbIpRecvState_None)
    491             msWait = RT_MIN(1000, aMillies);
     496            msWait = RT_MIN(3000, aMillies);
    492497
    493498        rc = RTPoll(m->hPollSet, msWait, &fEventsRecv, &uIdReady);
     
    563568                             || rc == VERR_NET_CONNECTION_REFUSED)
    564569                    {
    565                         /* Make sure the device list is clear. */
    566 #if 0
    567                         RTSemFastMutexRequest(m->hMtxDevices);
    568                         if (m->pUsbDevicesCur)
    569                         {
    570                             freeDeviceList(m->pUsbDevicesCur);
     570                        if (hasDevListChanged(m->pHead))
    571571                            fDeviceListChangedOrWokenUp = true;
    572                             m->cUsbDevicesCur = 0;
    573                             m->pUsbDevicesCur = NULL;
    574                         }
    575                         RTSemFastMutexRelease(m->hMtxDevices);
    576 #endif
    577572                        rc = VINF_SUCCESS;
    578573                    }
     
    739734        }
    740735        else
     736        {
    741737            LogFlowFunc(("Connected to host \"%s\"\n", m->pszHost));
     738            m->tsConnectSuccessLast = RTTimeMilliTS();
     739        }
     740    }
     741    else if (m->tsConnectSuccessLast + 10 * RT_MS_1SEC < RTTimeMilliTS())
     742    {
     743        /* Make sure the device list is clear if we failed to reconnect for some time. */
     744        RTSemFastMutexRequest(m->hMtxDevices);
     745        if (m->pUsbDevicesCur)
     746        {
     747            freeDeviceList(m->pUsbDevicesCur);
     748            m->cUsbDevicesCur = 0;
     749            m->pUsbDevicesCur = NULL;
     750        }
     751        RTSemFastMutexRelease(m->hMtxDevices);
    742752    }
    743753
Note: See TracChangeset for help on using the changeset viewer.

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