diff -urb clucene-core-0.9.21/configure.ac clucene-core-0.9.21b/configure.ac --- clucene-core-0.9.21/configure.ac 2008-09-21 08:19:46.000000000 +0200 +++ clucene-core-0.9.21b/configure.ac 2008-10-23 20:17:57.000000000 +0200 @@ -6,14 +6,14 @@ AC_INIT(src/CLucene/StdHeader.h) dnl the clucene-core package version -VERSION=0.9.21 +VERSION=0.9.21b dnl increment if interfaces have been added, removed or changed clLIB_current=3 dnl increment if source code has changed dnl - set to zero if current is incremented -clLIB_revision=0 +clLIB_revision=1 dnl increment if interfaces have been added dnl - set to zero if interfaces have been removed or changed diff -urb clucene-core-0.9.21/src/CLucene/queryParser/MultiFieldQueryParser.cpp clucene-core-0.9.21b/src/CLucene/queryParser/MultiFieldQueryParser.cpp --- clucene-core-0.9.21/src/CLucene/queryParser/MultiFieldQueryParser.cpp 2008-08-22 16:40:15.000000000 +0200 +++ clucene-core-0.9.21b/src/CLucene/queryParser/MultiFieldQueryParser.cpp 2008-10-23 19:44:35.000000000 +0200 @@ -36,7 +36,10 @@ int32_t i = 0; while ( fields[i] != NULL ){ Query* q = QueryParser::parse(query, fields[i], analyzer); + if (q && (q->getQueryName()!=_T("BooleanQuery") || ((BooleanQuery*)q)->getClauseCount() > 0)) { bQuery->add(q, true, false, false); + } else + _CLDELETE(q); i++; } @@ -51,6 +54,7 @@ while ( fields[i] != NULL ) { Query* q = QueryParser::parse(query, fields[i], analyzer); + if (q && (q->getQueryName()!=_T("BooleanQuery") || ((BooleanQuery*)q)->getClauseCount() > 0)) { uint8_t flag = flags[i]; switch (flag) { @@ -64,6 +68,9 @@ bQuery->add(q, true, false, false); break; } + } else { + _CLDELETE(q); + } i++; } diff -urb clucene-core-0.9.21/src/CLucene/store/FSDirectory.cpp clucene-core-0.9.21b/src/CLucene/store/FSDirectory.cpp --- clucene-core-0.9.21/src/CLucene/store/FSDirectory.cpp 2008-08-22 16:40:17.000000000 +0200 +++ clucene-core-0.9.21b/src/CLucene/store/FSDirectory.cpp 2008-10-23 20:01:52.000000000 +0200 @@ -65,7 +65,7 @@ if ( other.handle == NULL ) _CLTHROWA(CL_ERR_NullPointer, "other handle is null"); - SCOPED_LOCK_MUTEX(other.handle->THIS_LOCK) + SCOPED_LOCK_MUTEX(*other.handle->THIS_LOCK) handle = _CL_POINTER(other.handle); _pos = other.handle->_fpos; //note where we are currently... } @@ -75,6 +75,10 @@ _length = 0; _fpos = 0; path[0]=0; + +#ifdef _LUCENE_THREADMUTEX + THIS_LOCK = new _LUCENE_THREADMUTEX; +#endif } FSDirectory::FSIndexInput::SharedHandle::~SharedHandle() throw(CLuceneError&){ if ( fhandle >= 0 ){ @@ -100,7 +104,31 @@ } void FSDirectory::FSIndexInput::close() { BufferedIndexInput::close(); +#ifdef _LUCENE_THREADMUTEX + if ( handle != NULL ){ + //here we have a bit of a problem... we need to lock the handle to ensure that we can + //safely delete the handle... but if we delete the handle, then the scoped unlock, + //won't be able to unlock the mutex... + + //take a reference of the lock object... + _LUCENE_THREADMUTEX* mutex = handle->THIS_LOCK; + //lock the mutex + mutex->lock(); + + //determine if we are about to delete the handle... + bool dounlock = ( handle->__cl_refcount > 1 ); + //decdelete (deletes if refcount is down to 0 _CLDECDELETE(handle); + + if ( dounlock ){ + mutex->unlock(); + }else{ + delete mutex; + } + } +#else + _CLDECDELETE(handle); +#endif } void FSDirectory::FSIndexInput::seekInternal(const int64_t position) { @@ -110,7 +138,7 @@ /** IndexInput methods */ void FSDirectory::FSIndexInput::readInternal(uint8_t* b, const int32_t len) { - SCOPED_LOCK_MUTEX(handle->THIS_LOCK) + SCOPED_LOCK_MUTEX(*handle->THIS_LOCK) CND_PRECONDITION(handle!=NULL,"shared file handle has closed"); CND_PRECONDITION(handle->fhandle>=0,"file is not open"); diff -urb clucene-core-0.9.21/src/CLucene/store/FSDirectory.h clucene-core-0.9.21b/src/CLucene/store/FSDirectory.h --- clucene-core-0.9.21/src/CLucene/store/FSDirectory.h 2008-08-22 16:40:17.000000000 +0200 +++ clucene-core-0.9.21b/src/CLucene/store/FSDirectory.h 2008-10-23 20:00:43.000000000 +0200 @@ -86,7 +86,7 @@ int32_t fhandle; int64_t _length; int64_t _fpos; - DEFINE_MUTEX(THIS_LOCK) + DEFINE_MUTEX(*THIS_LOCK) char path[CL_MAX_DIR]; //todo: this is only used for cloning, better to get information from the fhandle SharedHandle(); ~SharedHandle() throw(CLuceneError&);