Ignore:
Timestamp:
2011-10-13T21:20:36+13:00 (13 years ago)
Author:
ak19
Message:

Corrections to code to prevent server crash when swapping indexers from MG to another 2 thereafter: mgsearch needs to be set to NULL when the collection server is deleted (which indirectly deletes the mgsearch object), since other parts of the code test against mgsearch being null. The same is done for mgppsearch lucenesearch objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/colservr/collectset.cpp

    r22067 r24757  
    507507    ++here;
    508508  }
     509  // since all collection server objects are deleted (which deleted their source objects
     510  // which in turn deleted their search objects), we now NULL the local reference to the
     511  // search objects. See the extensive comment for this in remove_collection(text_t).
     512#ifdef ENABLE_MG
     513      if (mgsearch != NULL) {
     514        mgsearch = NULL;
     515      }
     516#endif
     517#ifdef ENABLE_MGPP
     518      if (mgppsearch != NULL) {
     519        mgppsearch = NULL;
     520      }
     521#endif
     522#ifdef ENABLE_LUCENE
     523      if (lucenesearch != NULL) {
     524        lucenesearch = NULL;
     525      }
     526#endif
     527
    509528  cservers.clear();
    510529}
     
    583602    if ((*here).second.c != NULL && (*here).first == collection) {
    584603      delete (*here).second.c;
    585       cservers.erase (here);
     604
     605      // The above code deletes the collection server object for this collection, which then
     606      // deletes the <indexer>source object, which then deletes the <indexer>search object.
     607      // Since we have a reference to the <index>search object here, we have to set it to NULL
     608      // at this point, because we test it against null-ness elsewhere in this code. (Without
     609      // setting it to NULL, we end up with server crashing issues.)
     610      // Ideally, we'd like to know that we are NULLing the pointer to the exact same object
     611      // as was freed above, but we can't know that without complicated object access to make
     612      // the necessary pointer comparison. Fortunately, this class maintains only one type of
     613      // <index>search object (of a/any kind) at any time, so we can NULL this confidently now.
     614#ifdef ENABLE_MG
     615      if (mgsearch != NULL) {
     616        mgsearch = NULL;
     617      }
     618#endif
     619#ifdef ENABLE_MGPP
     620      if (mgppsearch != NULL) {
     621        mgppsearch = NULL;
     622      }
     623#endif
     624#ifdef ENABLE_LUCENE
     625      if (lucenesearch != NULL) {
     626        lucenesearch = NULL;
     627      }
     628#endif
     629
     630       // continue cleaning up the collection server
     631       cservers.erase (here);
     632
    586633      return;
    587     }
     634    } // end if
    588635    ++here;
    589636  }
     
    600647
    601648  outconvertclass text_t2ascii;
    602   logout << text_t2ascii << "collectset::remove_collection: failed to remove collectserver for "
     649  logout << text_t2ascii << "collectset::remove_collection: Removed collectserver for "
    603650     << collection << "\n";
    604651}
Note: See TracChangeset for help on using the changeset viewer.