lib/upnp/Discovery: use CURL instead of UpnpDownloadUrlItem()

We can do CURL requests asynchronously, and we don't need a
synchronous WorkQueue thread for that.

This allows parallelizing lookups and allows immediate cancellation.
This commit is contained in:
Max Kellermann
2017-01-26 09:34:53 +01:00
parent 28a2d41b85
commit c8f7a859ea
7 changed files with 157 additions and 297 deletions

View File

@@ -53,11 +53,14 @@ class UpnpNeighborExplorer final
}
};
EventLoop &event_loop;
UPnPDeviceDirectory *discovery;
public:
UpnpNeighborExplorer(NeighborListener &_listener)
:NeighborExplorer(_listener) {}
UpnpNeighborExplorer(EventLoop &_event_loop,
NeighborListener &_listener)
:NeighborExplorer(_listener), event_loop(_event_loop) {}
/* virtual methods from class NeighborExplorer */
void Open() override;
@@ -76,7 +79,7 @@ UpnpNeighborExplorer::Open()
UpnpClient_Handle handle;
UpnpClientGlobalInit(handle);
discovery = new UPnPDeviceDirectory(handle, this);
discovery = new UPnPDeviceDirectory(event_loop, handle, this);
try {
discovery->Start();
@@ -126,11 +129,11 @@ UpnpNeighborExplorer::LostUPnP(const ContentDirectoryService &service)
}
static NeighborExplorer *
upnp_neighbor_create(gcc_unused EventLoop &loop,
upnp_neighbor_create(EventLoop &event_loop,
NeighborListener &listener,
gcc_unused const ConfigBlock &block)
{
return new UpnpNeighborExplorer(listener);
return new UpnpNeighborExplorer(event_loop, listener);
}
const NeighborPlugin upnp_neighbor_plugin = {