Changeset 25244

Show
Ignore:
Timestamp:
21.03.2012 20:05:50 (8 years ago)
Author:
ak19
Message:

GS3 tomcat server crashes because java crashes owing to some error in the JNI code. The error may be related to pointers having been stored as int rather than long, an issue that's become noticeable on 64 bit linux machines. Changes have been made in the JNI code where these pointers that are transferred between Java and C++ code are stored (GetIntField? and SetIntField? to GetLongField? and SetLongField?, as well as declaration of data_ptr as jlong not jint). Committing code first without debug statements so the commits can easily be done separately.

Location:
main/trunk/greenstone2/common-src/indexers
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/mg/jni/MGRetrieveWrapperImpl.c

    r25147 r25244  
    180180 
    181181  /* Save the object on the Java side */ 
    182   (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (mg_s_long) data); 
     182  (*j_env)->SetLongField(j_env, j_obj, FID_mg_data, (long) data); 
    183183 
    184184  /* Initialise MG environment variables */ 
     
    213213                      jstring j_index) 
    214214{ 
    215   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     215  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    216216 
    217217  /* Get the index name as a C string */ 
     
    243243                         jlong j_docnum) 
    244244{ 
    245   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     245  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    246246 
    247247  char* index_path; 
  • main/trunk/greenstone2/common-src/indexers/mg/jni/MGSearchWrapperImpl.c

    r25147 r25244  
    142142 
    143143  /* Save the object on the Java side */ 
    144   (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (long) data); 
     144  (*j_env)->SetLongField(j_env, j_obj, FID_mg_data, (long) data); 
    145145 
    146146  /* Initialise MG environment variables */ 
     
    252252                      jstring j_query) 
    253253{ 
    254   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     254  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    255255 
    256256  char* index_path; 
     
    517517                     jboolean j_on) 
    518518{ 
    519   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     519  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    520520 
    521521  if (j_on) { 
     
    532532                     jboolean j_on) 
    533533{ 
    534   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     534  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    535535 
    536536  if (j_on) { 
     
    547547                        jint j_max) 
    548548{ 
    549   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     549  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    550550  data->queryInfo->maxDocs = j_max; 
    551551} 
     
    570570                        jboolean j_on) 
    571571{ 
    572   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     572  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    573573  data->queryInfo->needTermFreqs = j_on; 
    574574} 
     
    580580                      jstring j_index) 
    581581{ 
    582   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     582  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    583583 
    584584  /* Get the index name as a C string */ 
     
    606606                          jint j_mode) 
    607607{ 
    608   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     608  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    609609  data->defaultBoolCombine = j_mode; 
    610610} 
     
    615615Java_org_greenstone_mg_MGSearchWrapper_getQueryParams(JNIEnv *j_env, jobject j_obj) 
    616616{ 
    617   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     617  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    618618  char result[512];  /* Assume this is big enough */ 
    619619 
  • main/trunk/greenstone2/common-src/indexers/mg/jni/MGWrapperImpl.c

    r25147 r25244  
    168168 
    169169  /* Save the object on the Java side */ 
    170   (*j_env)->SetIntField(j_env, j_obj, FID_mg_data, (mg_s_long) data); 
     170  (*j_env)->SetLongField(j_env, j_obj, FID_mg_data, (long) data); 
    171171 
    172172  /* Initialise MG environment variables */ 
     
    278278                         jlong j_docnum) 
    279279{ 
    280   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     280  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    281281 
    282282  char* index_path; 
     
    363363                      jstring j_query) 
    364364{ 
    365   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     365  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    366366 
    367367  char* index_path; 
     
    628628                     jboolean j_on) 
    629629{ 
    630   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     630  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    631631 
    632632  if (j_on) { 
     
    643643                     jboolean j_on) 
    644644{ 
    645   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     645  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    646646 
    647647  if (j_on) { 
     
    658658                        jint j_max) 
    659659{ 
    660   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     660  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    661661  data->queryInfo->maxDocs = j_max; 
    662662} 
     
    681681                        jboolean j_on) 
    682682{ 
    683   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     683  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    684684  data->queryInfo->needTermFreqs = j_on; 
    685685} 
     
    691691                      jstring j_index) 
    692692{ 
    693   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     693  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    694694 
    695695  /* Get the index name as a C string */ 
     
    717717                          jint j_mode) 
    718718{ 
    719   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     719  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    720720  data->defaultBoolCombine = j_mode; 
    721721} 
     
    726726Java_org_greenstone_mg_MGWrapper_getQueryParams(JNIEnv *j_env, jobject j_obj) 
    727727{ 
    728   MGWrapperData* data = (MGWrapperData*) (*j_env)->GetIntField(j_env, j_obj, FID_mg_data); 
     728  MGWrapperData* data = (MGWrapperData*) (*j_env)->GetLongField(j_env, j_obj, FID_mg_data); 
    729729  char result[512];  /* Assume this is big enough */ 
    730730 
  • main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.cpp

    r16583 r25244  
    163163 
    164164  MGPPSearchData * data = new MGPPSearchData(); 
    165   j_env->SetIntField(j_obj, FID_mgpp_data, (long)data); 
     165  j_env->SetLongField(j_obj, FID_mgpp_data, (long)data); 
    166166 
    167167  return true; 
     
    178178Java_org_greenstone_mgpp_MGPPSearchWrapper_loadIndexData (JNIEnv *j_env, jobject j_obj,  jstring j_index_name) { 
    179179 
    180   jint data_ptr = j_env->GetIntField(j_obj, FID_mgpp_data); 
     180  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data); 
    181181  MGPPSearchData * data = (MGPPSearchData *)data_ptr; 
    182182 
     
    210210Java_org_greenstone_mgpp_MGPPSearchWrapper_unloadIndexData (JNIEnv *j_env, jobject j_obj) { 
    211211 
    212   jint data_ptr = j_env->GetIntField(j_obj, FID_mgpp_data); 
     212  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data); 
    213213  MGPPSearchData * data = (MGPPSearchData *)data_ptr; 
    214214 
     
    234234   
    235235  // the query data 
    236   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     236  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    237237   
    238238  // the result to write to 
     
    335335                          jobject j_obj,  
    336336                          jboolean j_on) { 
    337   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     337  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    338338  if (j_on) { 
    339339    data->defaultStemMethod |= 2; 
     
    348348                          jobject j_obj,  
    349349                          jboolean j_on) { 
    350   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     350  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    351351  if (j_on) { 
    352352    data->defaultStemMethod |= 4; 
     
    361361                          jobject j_obj,  
    362362                          jboolean j_on) { 
    363   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     363  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    364364 
    365365  if (j_on) { 
     
    374374                         jobject j_obj,  
    375375                         jint j_max) { 
    376   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     376  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    377377  data->queryInfo->maxDocs=j_max; 
    378378} 
     
    382382                         jobject j_obj,  
    383383                         jint j_max) { 
    384   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     384  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    385385  data->maxNumeric=j_max; 
    386386} 
     
    390390                            jobject j_obj,  
    391391                            jboolean j_on) { 
    392   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     392  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    393393   
    394394  data->queryInfo->sortByRank=j_on; 
     
    399399                            jobject j_obj,  
    400400                            jboolean j_on) { 
    401   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     401  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    402402  data->queryInfo->needTermFreqs = j_on; 
    403403  
     
    409409                           jstring j_level){ 
    410410   
    411   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     411  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    412412 
    413413  const char * level = j_env->GetStringUTFChars(j_level, NULL); 
     
    429429                            jstring j_level){ 
    430430 
    431   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     431  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data); 
     432  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
     433 
    432434 
    433435  const char * level = j_env->GetStringUTFChars(j_level, NULL); 
     
    441443  // release the java stuff 
    442444  j_env->ReleaseStringUTFChars(j_level, level); 
    443      
    444445 
    445446} 
     
    450451                           jint j_mode){ 
    451452 
    452   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     453  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    453454  data->defaultBoolCombine=j_mode; 
    454455 
     
    459460                             jobject j_obj){ 
    460461 
    461   MGPPSearchData * data = (MGPPSearchData *)j_env->GetIntField(j_obj, FID_mgpp_data); 
     462  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data); 
    462463   
    463464  // print the data to a stringstream, then convert to char*, then to