fix timeouts for mh_execm filters

This commit is contained in:
Jean-Francois Dockes
2015-10-08 10:10:04 +02:00
parent 5f1b10179d
commit ffc7d04bdf
7 changed files with 101 additions and 50 deletions
+15 -1
View File
@@ -907,8 +907,22 @@ int ExecCmd::getline(string& data)
}
const int BS = 1024;
char buf[BS];
int n = con->getline(buf, BS);
int timeosecs = m->m_timeoutMs / 1000;
if (timeosecs == 0)
timeosecs = 1;
// Note that we only go once through here, except in case of
// timeout, which is why I think that the goto is more expressive
// than a loop
again:
int n = con->getline(buf, BS, timeosecs);
if (n < 0) {
if (con->timedout()) {
LOGDEB(("ExecCmd::getline: timeout\n"));
if (m->m_advise)
m->m_advise->newData(0);
goto again;
}
LOGERR(("ExecCmd::getline: error\n"));
} else if (n > 0) {
data.append(buf, n);
+1 -2
View File
@@ -117,8 +117,7 @@ int Netcon::select1(int fd, int timeo, int write)
ret = select(fd+1, &rd, 0, 0, &tv);
}
if (!FD_ISSET(fd, &rd)) {
LOGERR(("Netcon::select1: fd not ready after select ??\n"));
return -1;
LOGDEB2(("Netcon::select1: fd %d timeout\n",fd));
}
return ret;
}