Change the timeout mechanism in inotify index.

This commit is contained in:
zhangzihao 2021-01-23 10:13:13 +08:00
parent 0dda5b97e5
commit 2d7b3a8eb1
1 changed files with 5 additions and 5 deletions

View File

@ -338,21 +338,21 @@ fork:
int rc; int rc;
timeval* read_timeout = (timeval*)malloc(sizeof(timeval)); timeval* read_timeout = (timeval*)malloc(sizeof(timeval));
read_timeout->tv_sec = 60;
read_timeout->tv_usec = 0;
for(;;) for(;;)
{ {
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
FD_SET(m_fd, &read_fds); FD_SET(m_fd, &read_fds);
read_timeout->tv_sec = 30; qDebug() << read_timeout->tv_sec;
read_timeout->tv_usec = 0;
rc = select(m_fd + 1, &read_fds, NULL, NULL, read_timeout); rc = select(m_fd + 1, &read_fds, NULL, NULL, read_timeout);
if ( rc < 0 ) { if ( rc < 0 ) {
// error // error
qDebug() << "rc < 0"; qWarning() << "select result < 0, error!";
assert(false); assert(false);
} }
else if ( rc == 0 ) { else if ( rc == 0 ) {
qDebug() << "timeout"; qDebug() << "select timeout!";
_exit(0); _exit(0);
}else{ }else{
numRead = read(m_fd, buf, BUF_LEN); numRead = read(m_fd, buf, BUF_LEN);