Uploaded image for project: 'MediaPortal 2'
  1. MediaPortal 2
  2. MP2-356

NetworkNeighborhoodResourceProvider showing multiple, duplicated servers in the network

    XMLWordPrintable

Details

    Description

      In some situations, the NetworkNeighborhoodResourceProvider shows multiple, duplicated servers in the network.

      This is caused by the EnumerateResources method in NetworkResourcesEnumerator. This method is supposed to return a List of servers in the network. It does so by calling the Win32 API function WNetOpenEnum for the root node and then iterating through the results via calling WNetEnumResource. If it finds a result, which itself is a container object (i.e. containing subentries) it recursively calls EnumerateResources but not starting with the root node, but with the respective container.

      There are situattions, in which a call to WNetEnumResource returns a NetResource object, which looks like this:

      NetResource:
          lpLocalName : ''
          lpRemoteName: ''
          lpComment: ''
          lpProvider: 'Microsoft Windows Network'
          dwScope: 'GlobalNet'
          dwType: 'Any'
          dwDisplayType: 'Domain'
          dwUsage: 'Container'

      Since this is a container object, it leads to EnumerateResources being called resucrsively, starting with this container object as root. However, becasue the lpLocalName is Null or empty, WNetOpenEnum thinks it is supposed to start enumerating the root of the whole Network neighborhood and so the whole process starts from the beginning until it finds the object above again. Then we are basically in an endless loop.

      The loop stops, when a call to WNetOpenEnum returns with error code 8 (ERROR_NOT_ENOUGH_MEMORY). Then it finishes all the recursive calls to EnumerateResources and finds all the servers in the network correctly, but once for each and every (wrong) recursive call. This leads to all the servers being displayed multiple times, each.

      The reason why this strange object is returned is unclear, but in any case it should not lead to servers being displayed multiple times in MP2.

      A solutions may be to only call EnumerateResources recursively if
         the respective object is a container AND
         lpRemoteName of this object is not NULL or empty

      This way, we won't get resources without a lpRemoteName, but these resources just don't make any sense.

      Attachments

        Activity

          People

            MJGraf MJGraf (Inactive)
            MJGraf MJGraf (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: