From c3065a86c6830ab0f723cee51dc2487cea5065be Mon Sep 17 00:00:00 2001 From: tchernobog Date: Fri, 10 Mar 2006 11:38:10 +0000 Subject: [PATCH] - 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 --- ChangeLog | 12 ++++++++++++ src/backend/pyloader/python_policy.cc | 26 +++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43717ac..624b0de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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, diff --git a/src/backend/pyloader/python_policy.cc b/src/backend/pyloader/python_policy.cc index 5017b8a..017a616 100644 --- a/src/backend/pyloader/python_policy.cc +++ b/src/backend/pyloader/python_policy.cc @@ -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(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);