mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
CLOUD: Fix ConnectionManager's destructor
It now terminates active Requests.
This commit is contained in:
parent
a66322408f
commit
1f974a7a2a
@ -43,6 +43,19 @@ ConnectionManager::ConnectionManager(): _multi(0), _timerStarted(false) {
|
||||
}
|
||||
|
||||
ConnectionManager::~ConnectionManager() {
|
||||
//terminate all requests
|
||||
_handleMutex.lock();
|
||||
for (Common::Array<RequestWithCallback>::iterator i = _requests.begin(); i != _requests.end(); ++i) {
|
||||
Request *request = i->request;
|
||||
RequestCallback callback = i->callback;
|
||||
if (request) request->finish();
|
||||
delete request;
|
||||
if (callback) (*callback)(request);
|
||||
}
|
||||
_requests.clear();
|
||||
_handleMutex.unlock();
|
||||
|
||||
//cleanup
|
||||
curl_multi_cleanup(_multi);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
@ -80,10 +93,11 @@ void ConnectionManager::stopTimer() {
|
||||
}
|
||||
|
||||
void ConnectionManager::handle() {
|
||||
//TODO: lock mutex here (in case another handle() would be called before this one ends)
|
||||
//lock mutex here (in case another handle() would be called before this one ends)
|
||||
_handleMutex.lock();
|
||||
interateRequests();
|
||||
processTransfers();
|
||||
//TODO: unlock mutex here
|
||||
_handleMutex.unlock();
|
||||
}
|
||||
|
||||
void ConnectionManager::interateRequests() {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "common/str.h"
|
||||
#include "common/singleton.h"
|
||||
#include "common/hashmap.h"
|
||||
#include "common/mutex.h"
|
||||
|
||||
typedef void CURL;
|
||||
typedef void CURLM;
|
||||
@ -51,6 +52,7 @@ class ConnectionManager : public Common::Singleton<ConnectionManager> {
|
||||
CURLM *_multi;
|
||||
bool _timerStarted;
|
||||
Common::Array<RequestWithCallback> _requests;
|
||||
Common::Mutex _handleMutex;
|
||||
|
||||
void startTimer(int interval = 1000000); //1 second is the default interval
|
||||
void stopTimer();
|
||||
|
@ -67,6 +67,9 @@
|
||||
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
#include "common/cloudmanager.h"
|
||||
#ifdef USE_LIBCURL
|
||||
#include "backends/networking/curl/connectionmanager.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "backends/platform/wince/CELauncherDialog.h"
|
||||
@ -591,6 +594,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
|
||||
launcherDialog();
|
||||
}
|
||||
}
|
||||
#ifdef USE_LIBCURL
|
||||
Networking::ConnectionManager::destroy();
|
||||
#endif
|
||||
PluginManager::instance().unloadAllPlugins();
|
||||
PluginManager::destroy();
|
||||
GUI::GuiManager::destroy();
|
||||
|
Loading…
x
Reference in New Issue
Block a user