Changeset 1598


Ignore:
Timestamp:
05/07/11 11:55:15 (11 months ago)
Author:
Tobias Richter
Message:

changes to fix the threading problems in the error reporting
refs #219

Location:
branches/4.2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/bindings/java/native/NexusFile.c

    r1427 r1598  
    3737   the integer first before it can do useful work. 
    3838 
    39  
    4039*/ 
    4140#include <stdlib.h> 
     
    5352#endif 
    5453 
    55 //#define DEBUG  
    56 #ifdef DEBUG 
    57 static FILE *fd = NULL; 
    58 #endif 
    59  
    60 static jclass nexusException;  // Global variable 
     54/* #define DEBUG */ 
     55 
    6156static JavaVM *jvm;  // Global variable 
    6257 
    6358JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { 
    6459    JNIEnv *env; 
     60    jclass nexusException;   
    6561 
    6662    jint ret = (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_1); 
     
    6864    assert(ret == JNI_OK); 
    6965 
    70     // Find and store the NexusException class for use in JapiError 
     66    jvm = vm; 
     67 
    7168    nexusException = (*env)->FindClass(env,"org/nexusformat/NexusException"); 
    72     assert(nexusException); 
    73  
    74     jvm = vm; 
     69    if (nexusException == NULL) { 
     70        fprintf(stderr, "cannot find NexusException - this will not work. Terminating."); 
     71        assert(nexusException); 
     72    } 
    7573 
    7674    return JNI_VERSION_1_1; 
     
    8482  --------------------------------------------------------------------------*/ 
    8583static void JapiError(void *pData, char *text) { 
    86     // better ignore the env passed in via pData, it is unsafe due to #219 
    87     JNIEnv *env; 
     84    JNIEnv *env = pData; 
     85    jclass nexusException;   
    8886 
    8987#ifdef DEBUG 
    90     fprintf(fd,"JapiError called with: %s\n", text);  
    91 #endif 
    92  
     88    fprintf(stderr,"JapiError called with: %s\n", text);  
     89#endif 
     90 
     91    /* ignore env passed in seems safer */ 
    9392    (*jvm)->AttachCurrentThread (jvm, (void **) &env, NULL); 
    9493 
     
    9897    } 
    9998 
     99    // Find and store the NexusException class for use in JapiError 
     100    nexusException = (*env)->FindClass(env,"org/nexusformat/NexusException"); 
    100101    (*env)->ThrowNew(env, nexusException, text); 
    101102}  
     
    111112    int iRet; 
    112113 
    113 #ifdef DEBUG 
    114     if(fd == NULL) 
    115     { 
    116         fd = fopen("jnexusdebug.dat","w"); 
    117     } 
    118 #endif     
    119     /* set error handler */ 
    120     NXMSetError(env,JapiError); 
     114    /* set error handler */ 
     115    NXMSetTError(env,JapiError); 
    121116 
    122117    /* extract the filename as a C char* */ 
    123     fileName = (char *) (*env)->GetStringUTFChars(env,filename,0);     
     118    fileName = (char *) (*env)->GetStringUTFChars(env, filename, 0);     
    124119     
    125120    /* call NXopen */ 
    126121#ifdef DEBUG 
    127     fprintf(fd,"Calling NXopen on %s, with %d\n", fileName,access); 
     122    fprintf(stderr,"Calling NXopen on %s, with %d\n", fileName, access); 
    128123#endif 
    129124    iRet = NXopen(fileName,access,&handle); 
    130125 
    131126#ifdef DEBUG 
    132     fprintf(fd,"Handle %d allocated for %s\n", handle, fileName); 
     127    fprintf(stderr,"Handle allocated for %s\n", fileName); 
    133128#endif 
    134129 
     
    155150 
    156151    /* set error handler */ 
    157     NXMSetError(env,JapiError); 
     152    NXMSetTError(env,JapiError); 
    158153 
    159154    /* exchange the Java handler to a NXhandle */ 
     
    162157    /* kill handle */ 
    163158    HHRemoveHandle(handle); 
    164  
    165159 
    166160    /* call NXflush */ 
     
    186180 
    187181    /* set error handler */ 
    188     NXMSetError(env,JapiError); 
     182    NXMSetTError(env,JapiError); 
    189183 
    190184    /* exchange the Java handler to a NXhandle */ 
    191185    nxhandle =  (NXhandle)HHGetPointer(handle); 
    192186#ifdef DEBUG 
    193     fprintf(fd,"closing handle %d, nxhandle %d\n", handle, nxhandle); 
     187    fprintf(stderr,"closing handle %d, nxhandle %d\n", handle, nxhandle); 
    194188#endif 
    195189 
     
    210204 
    211205    /* set error handler */ 
    212     NXMSetError(env,JapiError); 
     206    NXMSetTError(env,JapiError); 
    213207 
    214208    /* exchange the Java handler to a NXhandle */ 
     
    237231 
    238232    /* set error handler */ 
    239     NXMSetError(env,JapiError); 
     233    NXMSetTError(env,JapiError); 
    240234 
    241235    /* exchange the Java handler to a NXhandle */ 
     
    251245    if(iRet != NX_OK) 
    252246    { 
    253       fprintf(fd,"Cleanup code called after raising Exception\n"); 
     247      fprintf(stderr,"Cleanup code called after raising Exception\n"); 
    254248    } 
    255249#endif 
     
    269263 
    270264    /* set error handler */ 
    271     NXMSetError(env,JapiError); 
     265    NXMSetTError(env,JapiError); 
    272266 
    273267    /* exchange the Java handler to a NXhandle */ 
     
    282276    if(iRet != NX_OK) 
    283277    { 
    284       fprintf(fd,"Cleanup code called after raising Exception\n"); 
     278      fprintf(stderr,"Cleanup code called after raising Exception\n"); 
    285279    } 
    286280#endif 
     
    299293 
    300294    /* set error handler */ 
    301     NXMSetError(env,JapiError); 
     295    NXMSetTError(env,JapiError); 
    302296 
    303297    /* exchange the Java handler to a NXhandle */ 
     
    312306    if(iRet != NX_OK) 
    313307    { 
    314       fprintf(fd,"Cleanup code called after raising Exception\n"); 
     308      fprintf(stderr,"Cleanup code called after raising Exception\n"); 
    315309    } 
    316310#endif 
     
    327321 
    328322    /* set error handler */ 
    329     NXMSetError(env,JapiError); 
     323    NXMSetTError(env,JapiError); 
    330324 
    331325    /* exchange the Java handler to a NXhandle */ 
     
    347341 
    348342    /* set error handler */ 
    349     NXMSetError(env,JapiError); 
     343    NXMSetTError(env,JapiError); 
    350344 
    351345    /* exchange the Java handler to a NXhandle */ 
     
    368362 
    369363    /* set error handler */ 
    370     NXMSetError(env,JapiError); 
     364    NXMSetTError(env,JapiError); 
    371365 
    372366    /* exchange the Java handler to a NXhandle */ 
     
    399393 
    400394    /* set error handler */ 
    401     NXMSetError(env,JapiError); 
     395    NXMSetTError(env,JapiError); 
    402396 
    403397    /* exchange the Java handler to a NXhandle */ 
     
    433427 
    434428    /* set error handler */ 
    435     NXMSetError(env,JapiError); 
     429    NXMSetTError(env,JapiError); 
    436430 
    437431    /* exchange the Java handler to a NXhandle */ 
     
    456450 
    457451    /* set error handler */ 
    458     NXMSetError(env,JapiError); 
     452    NXMSetTError(env,JapiError); 
    459453 
    460454    /* exchange the Java handler to a NXhandle */ 
     
    474468 
    475469    /* set error handler */ 
    476     NXMSetError(env,JapiError); 
     470    NXMSetTError(env,JapiError); 
    477471 
    478472    /* exchange the Java handler to a NXhandle */ 
     
    480474 
    481475#ifdef DEBUG 
    482     fprintf(fd,"Compressing at %d with type %d\n", nxhandle, comp_type); 
     476    fprintf(stderr,"Compressing at %d with type %d\n", nxhandle, comp_type); 
    483477#endif 
    484478    iRet = NXcompress(nxhandle,comp_type); 
     
    495489 
    496490    /* set error handler */ 
    497     NXMSetError(env,JapiError); 
     491    NXMSetTError(env,JapiError); 
    498492 
    499493    /* exchange the Java handler to a NXhandle */ 
     
    510504    if(iRet != NX_OK) 
    511505    { 
    512         HEprint(fd,0); 
     506        HEprint(stderr,0); 
    513507    } 
    514508#endif 
     
    527521 
    528522    /* set error handler */ 
    529     NXMSetError(env,JapiError); 
     523    NXMSetTError(env,JapiError); 
    530524 
    531525    /* exchange the Java handler to a NXhandle */ 
     
    558552 
    559553    /* set error handler */ 
    560     NXMSetError(env,JapiError); 
     554    NXMSetTError(env,JapiError); 
    561555 
    562556    /* exchange the Java handler to a NXhandle */ 
     
    611605 
    612606    /* set error handler */ 
    613     NXMSetError(env,JapiError); 
     607    NXMSetTError(env,JapiError); 
    614608 
    615609    /* exchange the Java handler to a NXhandle */ 
     
    626620    if(iRet != NX_OK) 
    627621    { 
    628         HEprint(fd,0); 
     622        HEprint(stderr,0); 
    629623    } 
    630624#endif 
     
    643637 
    644638    /* set error handler */ 
    645     NXMSetError(env,JapiError); 
     639    NXMSetTError(env,JapiError); 
    646640 
    647641    /* exchange the Java handler to a NXhandle */ 
     
    676670 
    677671    /* set error handler */ 
    678     NXMSetError(env,JapiError); 
     672    NXMSetTError(env,JapiError); 
    679673 
    680674    /* exchange the Java handler to a NXhandle */ 
     
    686680    iargs = (*env)->GetIntArrayElements(env,args,0); 
    687681#ifdef DEBUG 
    688     fprintf(fd,"nxgetattr converted types \n"); 
     682    fprintf(stderr,"nxgetattr converted types \n"); 
    689683#endif 
    690684 
     
    692686    iType = iargs[1]; 
    693687#ifdef DEBUG 
    694     fprintf(fd,"nxgetattr: iLen %d, iType: %d\n",iLen, iType); 
     688    fprintf(stderr,"nxgetattr: iLen %d, iType: %d\n",iLen, iType); 
    695689#endif 
    696690 
     
    699693    iargs[1] = iType; 
    700694#ifdef DEBUG 
    701     fprintf(fd,"nxgetattr cleaning up \n"); 
     695    fprintf(stderr,"nxgetattr cleaning up \n"); 
    702696#endif 
    703697 
     
    721715 
    722716    /* set error handler */ 
    723     NXMSetError(env,JapiError); 
     717    NXMSetTError(env,JapiError); 
    724718 
    725719    /* exchange the Java handler to a NXhandle */ 
     
    733727        if(cls == NULL) 
    734728        { 
    735             NXIReportError(env, 
     729            JapiError(env, 
    736730               "ERROR: failed to locate class in nxgetgroupid"); 
    737731            return; 
     
    740734        if(fid == 0) 
    741735        { 
    742             NXIReportError(env, 
     736            JapiError(env, 
    743737               "ERROR: failed to locate fieldID in nxgetgroupid"); 
    744738            return; 
     
    749743        if(fid == 0) 
    750744        { 
    751             NXIReportError(env, 
     745            JapiError(env, 
    752746               "ERROR: failed to locate fieldID in nxgetgroupid"); 
    753747            return; 
     
    762756        if(fid == 0) 
    763757        { 
    764             NXIReportError(env, 
     758            JapiError(env, 
    765759               "ERROR: failed to locate targetPath in nxgetgroupid"); 
    766760            return; 
     
    772766        if(fid == 0) 
    773767        { 
    774             NXIReportError(env, 
     768            JapiError(env, 
    775769               "ERROR: failed to locate linkType in nxgetgroupid"); 
    776770            return; 
     
    782776        if(fid == 0) 
    783777        { 
    784             NXIReportError(env, 
     778            JapiError(env, 
    785779               "ERROR: failed to locate targetPath in nxgetgroupid"); 
    786780            return; 
     
    804798 
    805799    /* set error handler */ 
    806     NXMSetError(env,JapiError); 
     800    NXMSetTError(env,JapiError); 
    807801 
    808802    /* exchange the Java handler to a NXhandle */ 
     
    816810        if(cls == NULL) 
    817811        { 
    818             NXIReportError(env, 
     812            JapiError(env, 
    819813               "ERROR: failed to locate class in nxgetdataid"); 
    820814            return; 
     
    823817        if(fid == 0) 
    824818        { 
    825             NXIReportError(env, 
     819            JapiError(env, 
    826820               "ERROR: failed to locate fieldID in nxgetdataid"); 
    827821            return; 
     
    831825        if(fid == 0) 
    832826        { 
    833             NXIReportError(env, 
     827            JapiError(env, 
    834828               "ERROR: failed to locate fieldID in nxgetdataid"); 
    835829            return; 
     
    844838        if(fid == 0) 
    845839        { 
    846             NXIReportError(env, 
     840            JapiError(env, 
    847841               "ERROR: failed to locate targetPath in nxgetgroupid"); 
    848842            return; 
     
    854848        if(fid == 0) 
    855849        { 
    856             NXIReportError(env, 
     850            JapiError(env, 
    857851               "ERROR: failed to locate linkType in nxgetgroupid"); 
    858852            return; 
     
    864858        if(fid == 0) 
    865859        { 
    866             NXIReportError(env, 
     860            JapiError(env, 
    867861               "ERROR: failed to locate targetPath in nxgetdataid"); 
    868862            return; 
     
    888882 
    889883    /* set error handler */ 
    890     NXMSetError(env,JapiError); 
     884    NXMSetTError(env,JapiError); 
    891885 
    892886    /* exchange the Java handler to a NXhandle */ 
     
    897891    if(cls == NULL) 
    898892    { 
    899          NXIReportError(env, 
     893         JapiError(env, 
    900894               "ERROR: failed to locate class in nxmakelink"); 
    901895         return; 
     
    904898     if(fid == 0) 
    905899     { 
    906           NXIReportError(env, 
     900          JapiError(env, 
    907901               "ERROR: failed to locate fieldID in nxmakelink"); 
    908902          return; 
     
    912906     if(fid == 0) 
    913907     { 
    914           NXIReportError(env, 
     908          JapiError(env, 
    915909               "ERROR: failed to locate fieldID in nxmakelink"); 
    916910          return; 
     
    925919     if(fid == 0) 
    926920     { 
    927           NXIReportError(env, 
     921          JapiError(env, 
    928922               "ERROR: failed to locate targetPath in nxmakelink"); 
    929923          return; 
     
    937931     if(fid == 0) 
    938932     { 
    939           NXIReportError(env, 
     933          JapiError(env, 
    940934               "ERROR: failed to locate linkType in nxmakelink"); 
    941935          return; 
     
    947941     if(fid == 0) 
    948942     { 
    949           NXIReportError(env, 
     943          JapiError(env, 
    950944               "ERROR: failed to locate targetPath in nxmakelink"); 
    951945          return; 
     
    975969 
    976970    /* set error handler */ 
    977     NXMSetError(env,JapiError); 
     971    NXMSetTError(env,JapiError); 
    978972 
    979973    /* exchange the Java handler to a NXhandle */ 
     
    987981    if(cls == NULL) 
    988982    { 
    989          NXIReportError(env, 
     983         JapiError(env, 
    990984               "ERROR: failed to locate class in nxmakelink"); 
    991985         return; 
     
    994988     if(fid == 0) 
    995989     { 
    996           NXIReportError(env, 
     990          JapiError(env, 
    997991               "ERROR: failed to locate fieldID in nxmakelink"); 
    998992          return; 
     
    1002996     if(fid == 0) 
    1003997     { 
    1004           NXIReportError(env, 
     998          JapiError(env, 
    1005999               "ERROR: failed to locate fieldID in nxmakelink"); 
    10061000          return; 
     
    10151009     if(fid == 0) 
    10161010     { 
    1017           NXIReportError(env, 
     1011          JapiError(env, 
    10181012               "ERROR: failed to locate targetPath in nxmakelink"); 
    10191013          return; 
     
    10271021     if(fid == 0) 
    10281022     { 
    1029           NXIReportError(env, 
     1023          JapiError(env, 
    10301024               "ERROR: failed to locate linkType in nxmakelink"); 
    10311025          return; 
     
    10371031     if(fid == 0) 
    10381032     { 
    1039           NXIReportError(env, 
     1033          JapiError(env, 
    10401034               "ERROR: failed to locate targetPath in nxmakelink"); 
    10411035          return; 
     
    10611055 
    10621056    /* set error handler */ 
    1063     NXMSetError(env,JapiError); 
     1057    NXMSetTError(env,JapiError); 
    10641058 
    10651059    /* exchange the Java handler to a NXhandle */ 
     
    10801074 
    10811075   /* set error handler */ 
    1082     NXMSetError(env,JapiError); 
     1076    NXMSetTError(env,JapiError); 
    10831077 
    10841078    /* exchange the Java handler to a NXhandle */ 
     
    11101104 
    11111105   /* set error handler */ 
    1112     NXMSetError(env,JapiError); 
     1106    NXMSetTError(env,JapiError); 
    11131107 
    11141108    /* exchange the Java handler to a NXhandle */ 
     
    11451139 
    11461140   /* set error handler */ 
    1147     NXMSetError(env,JapiError); 
     1141    NXMSetTError(env,JapiError); 
    11481142 
    11491143    /* exchange the Java handler to a NXhandle */ 
     
    11731167    jint *jarray; 
    11741168   /* set error handler */ 
    1175     NXMSetError(env,JapiError); 
     1169    NXMSetTError(env,JapiError); 
    11761170 
    11771171    /* exchange the Java handler to a NXhandle */ 
     
    12001194 
    12011195   /* set error handler */ 
    1202     NXMSetError(env,JapiError); 
     1196    NXMSetTError(env,JapiError); 
    12031197 
    12041198    /* exchange the Java handler to a NXhandle */ 
     
    12191213 
    12201214    /* set error handler */ 
    1221     NXMSetError(env,JapiError); 
     1215    NXMSetTError(env,JapiError); 
    12221216 
    12231217    /* exchange the Java handler to a NXhandle */ 
     
    12451239     
    12461240    /* set error handler */ 
    1247     NXMSetError(env,JapiError); 
     1241    NXMSetTError(env,JapiError); 
    12481242 
    12491243    /* exchange the Java handler to a NXhandle */ 
     
    12731267 
    12741268    /* set error handler */ 
    1275     NXMSetError(env,JapiError); 
     1269    NXMSetTError(env,JapiError); 
    12761270 
    12771271    /* exchange the Java handler to a NXhandle */ 
     
    12891283 
    12901284    /* set error handler */ 
    1291     NXMSetError(env,JapiError); 
     1285    NXMSetTError(env,JapiError); 
    12921286 
    12931287    /* exchange the Java handler to a NXhandle */ 
     
    13101304   } 
    13111305} 
    1312  
    1313  
    1314  
    1315  
    1316  
    1317  
    1318  
    1319  
    1320  
  • branches/4.2/configure.ac

    r1455 r1598  
    131131        WITH_F90=no 
    132132fi 
     133 
     134AC_ARG_WITH([matlabroot], AC_HELP_STRING([--with-matlabroot=path to matlab install dir], [Specify location of matlab installation directory]), 
     135        [], [with_matlabroot=no]) 
     136if test x"$with_matlabroot" != x"no" ; then 
     137    MATLABROOT="$with_matlabroot" 
     138fi 
     139AC_PATH_PROG(MATLAB,matlab,[],[$MATLABROOT/bin:/usr/local/matlab/bin:/opt/matlab/bin:$PATH]) 
     140if test x"$MATLABROOT" = x -a x"$MATLAB" != x; then 
     141    MATLABROOT=`dirname $MATLAB`/.. 
     142fi 
     143 
     144dnl thread local storage 
     145AC_MSG_CHECKING([for __thread]) 
     146AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC__MINOR__ < 1) || (__GNUC__ == 4 && __GNUC__MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2)) 
     147#endif], [static __thread int p = 0])], 
     148               [AC_DEFINE(HAVE_TLS, 1, 
     149                      Define to 1 if compiler supports __thread) 
     150                AC_MSG_RESULT([yes])], 
     151               [AC_MSG_RESULT([no])]) 
    133152 
    134153java_host="linux" 
  • branches/4.2/include/napi.h

    r1453 r1598  
    728728 
    729729  /** 
    730    * Set an error function. 
    731    * \param pData A pointer to a user defined data structure which be passed opaquely to  
     730   * Set a global error function. 
     731   * Not threadsafe. 
     732   * \param pData A pointer to a user defined data structure which be passed to  
    732733   * the error display function. 
    733734   * \param newErr The new error display function. 
     
    736737 
    737738  /** 
     739   * Set an error function for the current thread. 
     740   * When used this overrides anything set in NXMSetError (for the current thread). 
     741   * Use this method in threaded applications. 
     742   * \param pData A pointer to a user defined data structure which be passed to  
     743   * the error display function. 
     744   * \param newErr The new error display function. 
     745   */ 
     746extern  void  NXMSetTError(void *pData, ErrFunc newErr); 
     747 
     748  /** 
    738749   * Retrieve the current error display function 
    739    * \return The current erro display function. 
     750   * \return The current error display function. 
    740751   */ 
    741752extern ErrFunc NXMGetError(); 
     
    752763 
    753764 
    754 extern void (*NXIReportError)(void *pData,char *text); 
     765extern void NXIReportError(void *pData,char *text); 
    755766extern void *NXpData; 
    756767extern char *NXIformatNeXusTime(); 
  • branches/4.2/src/napi.c

    r1429 r1598  
    178178  static void NXNXNXReportError(void *pData, char *string) 
    179179  { 
    180     printf("%s \n",string); 
     180    fprintf(stderr, "%s \n", string); 
    181181  } 
    182182  /*---------------------------------------------------------------------*/ 
     183 
    183184  void *NXpData = NULL; 
    184   void (*NXIReportError)(void *pData, char *string) = NXNXNXReportError; 
     185  void *NXEHpData = NULL; 
     186  void (*NXEHIReportError)(void *pData, char *string) = NXNXNXReportError; 
     187#ifdef HAVE_TLS 
     188  __thread void *NXEHpTData = NULL; 
     189  __thread void (*NXEHIReportTError)(void *pData, char *string) = NULL; 
     190#endif 
     191 
     192  void NXIReportError(void *pData, char *string) { 
     193#ifdef HAVE_TLS 
     194        if (NXEHIReportTError) { 
     195                (*NXEHIReportTError)(NXEHpTData, string); 
     196                return; 
     197        }  
     198#endif 
     199 
     200        (*NXEHIReportError)(NXEHpData, string); 
     201  } 
     202 
    185203  /*---------------------------------------------------------------------*/ 
    186   extern void NXMSetError(void *pData,  
    187                               void (*NewError)(void *pD, char *text)) 
    188   { 
    189     NXpData = pData; 
    190     NXIReportError = NewError; 
     204  extern void NXMSetError(void *pData, void (*NewError)(void *pD, char *text)) 
     205  { 
     206    NXEHpData = pData; 
     207    NXEHIReportError = NewError; 
     208  } 
     209/*----------------------------------------------------------------------*/ 
     210  extern void NXMSetTError(void *pData, void (*NewError)(void *pD, char *text)) 
     211  { 
     212#ifdef HAVE_TLS 
     213    NXEHpTData = pData; 
     214    NXEHIReportTError = NewError; 
     215#else 
     216    NXMSetError(pData, NewError); 
     217#endif 
    191218  } 
    192219/*----------------------------------------------------------------------*/ 
    193220extern ErrFunc NXMGetError(){ 
    194   return NXIReportError; 
     221#ifdef HAVE_TLS 
     222        if (NXEHIReportTError) { 
     223                return NXEHIReportTError; 
     224        } 
     225#endif 
     226  return NXEHIReportError; 
    195227} 
    196228 
     
    201233/*----------------------------------------------------------------------*/ 
    202234 
    203 static ErrFunc last_errfunc = NXNXNXReportError; 
     235ErrFunc last_global_errfunc = NXNXNXReportError; 
     236#ifdef HAVE_TLS 
     237__thread ErrFunc last_thread_errfunc = NULL; 
     238#endif 
    204239 
    205240extern void NXMDisableErrorReporting() 
    206241{ 
    207     last_errfunc = NXMGetError(); 
    208     NXMSetError(NXpData, NXNXNoReport); 
     242#ifdef HAVE_TLS 
     243        if (NXEHIReportTError) { 
     244                last_thread_errfunc = NXEHIReportTError; 
     245                NXEHIReportTError = NXNXNoReport; 
     246                return; 
     247        }  
     248        last_thread_errfunc = NULL; 
     249#endif 
     250        last_global_errfunc = NXEHIReportError; 
     251        NXEHIReportError = NXNXNoReport; 
    209252} 
    210253 
    211254extern void NXMEnableErrorReporting() 
    212255{ 
    213     NXMSetError(NXpData, last_errfunc); 
     256#ifdef HAVE_TLS 
     257        if (last_thread_errfunc) { 
     258                NXEHIReportTError = last_thread_errfunc; 
     259                last_thread_errfunc = NULL; 
     260                return; 
     261        }  
     262#endif 
     263        NXEHIReportError = last_global_errfunc; 
    214264} 
    215265 
     
    536586    pFileStack fileStack;     
    537587    char nxurl[1024], exfile[512], expath[512]; 
    538     ErrFunc oldError; 
    539588    pNexusFunction pFunc = NULL; 
    540589 
     
    546595      pushPath(fileStack,name); 
    547596    } 
    548     oldError = NXMGetError(); 
    549     NXIReportError = NXNXNoReport; 
     597    NXMDisableErrorReporting(); 
    550598    attStatus = NXgetattr(fid,"napimount",nxurl,&length, &type); 
    551     NXIReportError = oldError; 
     599    NXMEnableErrorReporting(); 
    552600    if(attStatus == NX_OK){ 
    553601      /* 
     
    10501098    return status; 
    10511099  } 
    1052   oldError = NXMGetError(); 
    1053   NXIReportError = NXNXNoReport; 
     1100  NXMDisableErrorReporting(); 
    10541101  attStatus = NXgetattr(fid,"napimount",nxurl,&length, &type); 
    1055   NXIReportError = oldError; 
     1102  NXMEnableErrorReporting(); 
    10561103  pFunc->nxclosegroup(pFunc->pNexusData); 
    10571104  if(attStatus == NX_OK){ 
  • branches/4.2/src/napi4.c

    r1427 r1598  
    12921292  { 
    12931293    pNexusFile pFile; 
    1294     ErrFunc oldErr; 
    12951294    int datalen, type = NX_CHAR; 
    12961295 
     
    13031302      sRes->iTag = DFTAG_NDG; 
    13041303      sRes->iRef = SDidtoref (pFile->iCurrentSDS); 
    1305       oldErr = NXMGetError(); 
    1306       NXMSetError(NXpData, ignoreError); 
     1304      NXMDisableErrorReporting(); 
    13071305      datalen = 1024; 
    13081306      memset(&sRes->targetPath,0,1024); 
     
    13111309        NXIbuildPath(pFile,sRes->targetPath,1024); 
    13121310      } 
    1313       NXMSetError(NXpData,oldErr); 
     1311      NXMEnableErrorReporting(); 
    13141312      return NX_OK; 
    13151313    } 
  • branches/4.2/src/napi5.c

    r1427 r1598  
    10501050  { 
    10511051    pNexusFile5 pFile; 
    1052     ErrFunc oldErr; 
    10531052    int datalen, type = NX_CHAR; 
    10541053   
     
    10661065      the path to the current node 
    10671066    */ 
    1068     oldErr = NXMGetError(); 
    1069     NXMSetError(NXpData, ignoreError); 
     1067    NXMDisableErrorReporting(); 
    10701068    datalen = 1024; 
    10711069    memset(&sRes->targetPath,0,datalen*sizeof(char)); 
     
    10741072      buildCurrentPath(pFile, sRes->targetPath, 1024); 
    10751073    } 
    1076     NXMSetError(NXpData,oldErr); 
     1074    NXMEnableErrorReporting(); 
    10771075    sRes->linkType = 1; 
    10781076    return NX_OK; 
     
    20312029    pNexusFile5 pFile; 
    20322030    int datalen, type = NX_CHAR; 
    2033     ErrFunc oldErr; 
    20342031   
    20352032    pFile = NXI5assert (fileid); 
     
    20422039        the path to the current node 
    20432040      */ 
    2044       oldErr = NXMGetError(); 
    2045       NXMSetError(NXpData, ignoreError); 
     2041      NXMDisableErrorReporting(); 
    20462042      datalen = 1024; 
    20472043      memset(sRes->targetPath,0,datalen*sizeof(char)); 
     
    20492045        buildCurrentPath(pFile,sRes->targetPath,1024); 
    20502046      } 
    2051       NXMSetError(NXpData,oldErr); 
     2047      NXMEnableErrorReporting(); 
    20522048      sRes->linkType = 0; 
    20532049      return NX_OK; 
  • branches/4.2/src/nexus_symbols.txt

    r1427 r1598  
    4747nxiisexternalgroup_ 
    4848NXMSetError 
     49NXMSetTError 
    4950NXIReportError 
    5051NXIprintlink 
  • branches/4.2/src/nxstack.c

    r1427 r1598  
    110110} 
    111111/*----------------------------------------------------------------------*/ 
    112 void pushPath(pFileStack self, char *name){ 
     112void pushPath(pFileStack self, const char *name){ 
    113113  self->pathPointer++; 
    114114  strncpy(self->pathStack[self->pathPointer],name,NX_MAXNAMELEN-1); 
  • branches/4.2/src/nxstack.h

    r1427 r1598  
    4545int fileStackDepth(pFileStack self); 
    4646 
    47 void pushPath(pFileStack self, char *name); 
     47void pushPath(pFileStack self, const char *name); 
    4848void popPath(pFileStack self); 
    4949int buildPath(pFileStack self, char *path, int pathlen); 
  • branches/4.2/src/nxxml.c

    r1427 r1598  
    17451745  path = (mxml_node_t **)malloc(NXMAXSTACK*sizeof(mxml_node_t *)); 
    17461746  if(path == NULL){ 
    1747     NXIReportError(NXpData,"ERROR: out of memory follwoing link path"); 
     1747    NXIReportError(NXpData,"ERROR: out of memory following link path"); 
    17481748    return NULL; 
    17491749  } 
     
    18991899/*--------------------------------------------------------------------*/ 
    19001900int  NXXcompress(NXhandle fid, int comp){ 
    1901   NXIReportError(NXpData,"NXcompress is deprecated, IGNORED"); 
     1901  /* that will throw an exception in the Java API, errors have to be fatal */ 
     1902  /* NXIReportError(NXpData,"NXcompress is deprecated, IGNORED"); */ 
    19021903  return NX_OK; 
    19031904} 
Note: See TracChangeset for help on using the changeset viewer.