- Fix bug with retval not treated as a bool value in wait_unlock()

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@523 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-03-10 11:38:10 +00:00
parent b6f23767cb
commit c3065a86c6
2 changed files with 25 additions and 13 deletions

View File

@ -1,3 +1,15 @@
2006-03-10 03:20 jinx
* trunk/doc/sgpem2uman.texi: Added chapters Overview of SGPEM and
Starting with SGPEM
2006-03-09 22:20 tchernobog
* trunk/ChangeLog, trunk/Makefile.am,
trunk/src/backend/pyloader/python_policy.cc,
trunk/src/testsuite/test-python_loader.cc: - Make
test-python_loader a unit test instead of an integration test
2006-03-09 21:56 tchernobog
* trunk/Makefile.am, trunk/src/backend/observed_subject.hh,

View File

@ -25,6 +25,8 @@
using namespace sgpem;
using namespace std;
#define WAIT_FOR (250000)
// WARNING : this class needs extensive and above all
// *strong* exception checking / handling!
@ -160,28 +162,26 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException)
int i = 0; // We give the sort_queue() three seconds max time, then...
// we shot it stone dead! Bang.
std::cout << "waiting unlock" << std::endl;
bool still_locked;
do
{
Py_UNBLOCK_THREADS;
usleep(25000); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
usleep(WAIT_FOR); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS;
PyObject* retval = PyObject_CallMethod(_lock, "test", NULL);
still_locked = static_cast<bool>(PyInt_AsLong(retval));
Py_DECREF(retval);
still_locked = PyBool_Check(retval);
Py_DECREF(retval);
if(i++ > 120)
if(i++ > WAIT_FOR*12)
{
PyThreadState_Clear(_save);
PyEval_RestoreThread(_save);
//Py_UNBLOCK_THREADS;
throw UserInterruptException("User-defined policy is "
"taking too long to terminate.");
PyThreadState_Clear(_save);
PyEval_RestoreThread(_save);
//Py_UNBLOCK_THREADS;
throw UserInterruptException("User-defined policy is "
"taking too long to terminate.");
}
}
while(still_locked);