Commit 852bd075 authored by Committed by Adrien BéraudBrowse files
upnp: Port mappings are not deleted upon IGD discovery anymore.
Part of the discovery event handling for libupnp was to delete all port mappings associated with the local ip address of the application. I can only assume this was done to close pre- existing ports that were not properly closed when the application terminated. The problem with this logic is that since advertisements and discovery events are treated with the same switch case (fall through), the application was trying to close all the ports on the internet gateway everytime it got an advertisement. However, the application would then try to reopen the ports every time after closing them. And this would happen every five to ten seconds (i.e. whenever the application would catch and advertisement or discovery event from the internet gateway.) To fix this quickly, I modified the way the event handling treats discovery and advertisement events. Instead of having a list based on the URL of the internet gateway, I use a list of it's unique service ID. That way, as soon as the event occurs, we check if we don't already have this service ID in our list. If we don't, then we proceed as usual. If we do, we exit the event handling since it's already been processed. The advertisement bye bye event has also been implemented. When this event occurs, the corresponding internet gateway devices are deleted from the lists. Gitlab: #96 Change-Id: Idd8023eba319b431b3a9328ebe648e75d61b1dc8