From d30e51ca632bdaf72be701d98ef283e289b78860 Mon Sep 17 00:00:00 2001 From: "jkand.huang" Date: Fri, 18 Oct 2019 15:23:21 +0800 Subject: [PATCH] MTP crashes while deleting files (hang while deleting) Signed-off-by: jkand.huang --- server/UbuntuMtpDatabase.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/UbuntuMtpDatabase.h b/server/UbuntuMtpDatabase.h index 29bd315..26b0308 100644 --- a/server/UbuntuMtpDatabase.h +++ b/server/UbuntuMtpDatabase.h @@ -1046,9 +1046,18 @@ public: * we can safely ignore failures here, since the objects * would not be reachable anyway. */ + /* BOOST_FOREACH(MtpObjectHandle i, db | boost::adaptors::map_keys) { if (db.at(i).parent == handle) db.erase(i); + }*/ + + for(std::map::iterator it = db.begin(); it != db.end();){ + if(it->second.parent == handle){ + db.erase(it++); + }else{ + it++; + } } return MTP_RESPONSE_OK; -- 2.7.4