summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-11-25 17:40:04 +0100
committerEthan Yonker <dees_troy@teamw.in>2014-11-25 22:00:08 +0100
commitcdc3ef5feb8421cdb6cd6850c75a7222c049fe23 (patch)
tree9bd102c8c937d01c32a6ba2a10e365387b46c02d
parentProperly set tw_settings_path after decrypt on data media devices (diff)
downloadandroid_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.tar
android_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.tar.gz
android_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.tar.bz2
android_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.tar.lz
android_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.tar.xz
android_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.tar.zst
android_bootable_recovery-cdc3ef5feb8421cdb6cd6850c75a7222c049fe23.zip
-rwxr-xr-xmtp/MtpStorage.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/mtp/MtpStorage.cpp b/mtp/MtpStorage.cpp
index 821a788f2..319be094b 100755
--- a/mtp/MtpStorage.cpp
+++ b/mtp/MtpStorage.cpp
@@ -53,6 +53,7 @@ MtpStorage::MtpStorage(MtpStorageID id, const char* filePath,
{
MTPI("MtpStorage id: %d path: %s\n", id, filePath);
inotify_thread = 0;
+ inotify_fd = -1;
sendEvents = false;
handleCurrentlySending = 0;
use_mutex = true;
@@ -127,9 +128,15 @@ int MtpStorage::createDB() {
mtpmap[0] = new Tree(0, 0, "");
MTPD("MtpStorage::createDB DONE\n");
if (use_mutex) {
- MTPD("Starting inotify thread\n");
sendEvents = true;
- inotify_thread = inotify();
+ MTPD("inotify_init\n");
+ inotify_fd = inotify_init();
+ if (inotify_fd < 0) {
+ MTPE("Can't run inotify_init for mtp server: %s\n", strerror(errno));
+ } else {
+ MTPD("Starting inotify thread\n");
+ inotify_thread = inotify();
+ }
} else {
MTPD("NOT starting inotify thread\n");
}
@@ -566,6 +573,10 @@ pthread_t MtpStorage::inotify(void) {
}
int MtpStorage::addInotify(Tree* tree) {
+ if (inotify_fd < 0) {
+ MTPE("inotify_fd not set or error: %i\n", inotify_fd);
+ return -1;
+ }
std::string path = getNodePath(tree);
MTPD("adding inotify for tree %x, dir: %s\n", tree, path.c_str());
int wd = inotify_add_watch(inotify_fd, path.c_str(), WATCH_FLAGS);
@@ -659,13 +670,7 @@ int MtpStorage::inotify_t(void) {
#define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16) )
char buf[EVENT_BUF_LEN];
- MTPD("inotify thread: inotify_init\n");
- inotify_fd = inotify_init();
-
- if (inotify_fd < 0) {
- MTPE("Can't run inotify for mtp server: %s\n", strerror(errno));
- return -1;
- }
+ MTPD("inotify thread starting.\n");
while (true) {
int i = 0;