also test cancel on select timeout
This commit is contained in:
parent
f920d2ce3e
commit
3188728dce
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: execmd.cpp,v 1.14 2006-01-26 17:44:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: execmd.cpp,v 1.15 2006-01-26 17:59:30 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -162,6 +162,8 @@ int ExecCmd::doexec(const string &cmd, const list<string>& args,
|
|||||||
if ((ss = select(nfds, &readfds, &writefds, 0, &tv)) <= 0) {
|
if ((ss = select(nfds, &readfds, &writefds, 0, &tv)) <= 0) {
|
||||||
if (ss == 0) {
|
if (ss == 0) {
|
||||||
// Timeout, is ok.
|
// Timeout, is ok.
|
||||||
|
if (m_advise)
|
||||||
|
m_advise->newData(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOGERR(("ExecCmd::doexec: select(2) failed. errno %d\n",
|
LOGERR(("ExecCmd::doexec: select(2) failed. errno %d\n",
|
||||||
@ -196,7 +198,7 @@ int ExecCmd::doexec(const string &cmd, const list<string>& args,
|
|||||||
// cerr << "READ: " << n << endl;
|
// cerr << "READ: " << n << endl;
|
||||||
output->append(buf, n);
|
output->append(buf, n);
|
||||||
if (m_advise)
|
if (m_advise)
|
||||||
m_advise->newData();
|
m_advise->newData(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +299,7 @@ const char *data = "Une ligne de donnees\n";
|
|||||||
class MEAdv : public ExecCmdAdvise {
|
class MEAdv : public ExecCmdAdvise {
|
||||||
public:
|
public:
|
||||||
ExecCmd *cmd;
|
ExecCmd *cmd;
|
||||||
void newData() {
|
void newData(int) {
|
||||||
cerr << "New Data!" << endl;
|
cerr << "New Data!" << endl;
|
||||||
CancelCheck::instance().setCancel();
|
CancelCheck::instance().setCancel();
|
||||||
CancelCheck::instance().checkCancel();
|
CancelCheck::instance().checkCancel();
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
#ifndef _EXECMD_H_INCLUDED_
|
#ifndef _EXECMD_H_INCLUDED_
|
||||||
#define _EXECMD_H_INCLUDED_
|
#define _EXECMD_H_INCLUDED_
|
||||||
/* @(#$Id: execmd.h,v 1.6 2006-01-26 17:44:51 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: execmd.h,v 1.7 2006-01-26 17:59:30 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
/** Callback function object to advise of new data arrival */
|
/** Callback function object to advise of new data arrival (or just heartbeat) * if cnt is 0 */
|
||||||
class ExecCmdAdvise {
|
class ExecCmdAdvise {
|
||||||
public:
|
public:
|
||||||
virtual ~ExecCmdAdvise() {}
|
virtual ~ExecCmdAdvise() {}
|
||||||
virtual void newData() = 0;
|
virtual void newData(int cnt) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user