Fix:Index init failed sometimes.

This commit is contained in:
iaom 2021-11-03 17:11:20 +08:00
parent c2905bc331
commit 8e3855e95a
1 changed files with 2 additions and 1 deletions

View File

@ -180,6 +180,7 @@ void InotifyWatch::run()
int rc; int rc;
rc = select(m_inotifyFd + 1, &fds, NULL, NULL, NULL); rc = select(m_inotifyFd + 1, &fds, NULL, NULL, NULL);
if(rc > 0) { if(rc > 0) {
++FileUtils::_index_status;
int avail; int avail;
if (ioctl(m_inotifyFd, FIONREAD, &avail) == EINVAL) { if (ioctl(m_inotifyFd, FIONREAD, &avail) == EINVAL) {
qWarning() << "Did not receive an entire inotify event."; qWarning() << "Did not receive an entire inotify event.";
@ -210,6 +211,7 @@ void InotifyWatch::run()
slotEvent(buf, len); slotEvent(buf, len);
free(buf); free(buf);
} }
--FileUtils::_index_status;
} else if(rc < 0) { } else if(rc < 0) {
// error // error
qWarning() << "select result < 0, error!"; qWarning() << "select result < 0, error!";
@ -301,7 +303,6 @@ void InotifyWatch::slotEvent(char *buf, ssize_t len)
m_sharedMemory->detach(); m_sharedMemory->detach();
currentPath = pathMap; currentPath = pathMap;
} }
--FileUtils::_index_status;
} else { } else {
assert(false); assert(false);
} }