do not sleep if it is shutting down
am: 375ac25773
Change-Id: I576040b0068c27b9c7abd880e390841ce80f9906
This commit is contained in:
commit
612270b598
3 changed files with 15 additions and 7 deletions
15
Utils.cpp
15
Utils.cpp
|
@ -17,6 +17,7 @@
|
||||||
#include "sehandle.h"
|
#include "sehandle.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
#include "VolumeManager.h"
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
@ -126,22 +127,22 @@ status_t ForceUnmount(const std::string& path) {
|
||||||
}
|
}
|
||||||
// Apps might still be handling eject request, so wait before
|
// Apps might still be handling eject request, so wait before
|
||||||
// we start sending signals
|
// we start sending signals
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
|
|
||||||
Process::killProcessesWithOpenFiles(cpath, SIGINT);
|
Process::killProcessesWithOpenFiles(cpath, SIGINT);
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Process::killProcessesWithOpenFiles(cpath, SIGTERM);
|
Process::killProcessesWithOpenFiles(cpath, SIGTERM);
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Process::killProcessesWithOpenFiles(cpath, SIGKILL);
|
Process::killProcessesWithOpenFiles(cpath, SIGKILL);
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -154,17 +155,17 @@ status_t KillProcessesUsingPath(const std::string& path) {
|
||||||
if (Process::killProcessesWithOpenFiles(cpath, SIGINT) == 0) {
|
if (Process::killProcessesWithOpenFiles(cpath, SIGINT) == 0) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
|
|
||||||
if (Process::killProcessesWithOpenFiles(cpath, SIGTERM) == 0) {
|
if (Process::killProcessesWithOpenFiles(cpath, SIGTERM) == 0) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
|
|
||||||
if (Process::killProcessesWithOpenFiles(cpath, SIGKILL) == 0) {
|
if (Process::killProcessesWithOpenFiles(cpath, SIGKILL) == 0) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
sleep(5);
|
if (!VolumeManager::shutting_down) sleep(5);
|
||||||
|
|
||||||
// Send SIGKILL a second time to determine if we've
|
// Send SIGKILL a second time to determine if we've
|
||||||
// actually killed everyone with open files
|
// actually killed everyone with open files
|
||||||
|
|
|
@ -89,6 +89,8 @@ const char *VolumeManager::ASECDIR = "/mnt/asec";
|
||||||
*/
|
*/
|
||||||
const char *VolumeManager::LOOPDIR = "/mnt/obb";
|
const char *VolumeManager::LOOPDIR = "/mnt/obb";
|
||||||
|
|
||||||
|
bool VolumeManager::shutting_down = false;
|
||||||
|
|
||||||
static const char* kPathUserMount = "/mnt/user";
|
static const char* kPathUserMount = "/mnt/user";
|
||||||
static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
|
static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
|
||||||
|
|
||||||
|
@ -704,12 +706,14 @@ int VolumeManager::shutdown() {
|
||||||
if (mInternalEmulated == nullptr) {
|
if (mInternalEmulated == nullptr) {
|
||||||
return 0; // already shutdown
|
return 0; // already shutdown
|
||||||
}
|
}
|
||||||
|
shutting_down = true;
|
||||||
mInternalEmulated->destroy();
|
mInternalEmulated->destroy();
|
||||||
mInternalEmulated = nullptr;
|
mInternalEmulated = nullptr;
|
||||||
for (const auto& disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->destroy();
|
disk->destroy();
|
||||||
}
|
}
|
||||||
mDisks.clear();
|
mDisks.clear();
|
||||||
|
shutting_down = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,9 @@ public:
|
||||||
static const char *ASECDIR;
|
static const char *ASECDIR;
|
||||||
static const char *LOOPDIR;
|
static const char *LOOPDIR;
|
||||||
|
|
||||||
|
//TODO remove this with better solution, b/64143519
|
||||||
|
static bool shutting_down;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static VolumeManager *sInstance;
|
static VolumeManager *sInstance;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue