CISAM problem on Solaris 2.5 with threads.
Posted in 1996
Topics: SQL Development & Query Writing, Server Administration, Platform-Specific Issues
Hello, I have the problem that i can't create a database file with C-ISAM in a multithreaded application. The application creates a thread which invokes the isbuild C-ISAM function. The call returns a 17 fault indicating a file exist error message (dixit informix). The thread also creates a textfile with a fopen call to verify the thread functionality. Can someone help me, or is C-ISAM unusable in a thread environment ? PS: the application is builded and tested on a 'SunOS btm05a 5.5 Generic sun4m sparc SUNW,SPARCstation-5' machine on a local partition. #####area.c#(end)################################################# #include <stdio.h> #include <errno.h> #include <isam.h> #include <thread.h> /* required to use threads */ #define ODB_MAX_AREA_NAME_LENGTH 63 #define ODB_MAX_DIRECTORY_NAME_LENGTH 240 static char database_filestub[] = "area" ; static char database_filestu2[] = "area.txt" ; static int fd ; static struct keydesc key0 = {ISNODUPS,1,{{0,LONGSIZE,LONGTYPE}}} ; static struct keydesc key1 = {ISNODUPS,2,{{LONGSIZE,LONGSIZE,LONGTYPE} , {0,LONGSIZE,LONGTYPE}}} ; static void create_dba( void ) { FILE * fptr ; char isam_record[LONGSIZE+LONGSIZE+ODB_MAX_AREA_NAME_LENGTH+ODB_MAX_DIRECTORY_NAME_LENGTH+LONGSIZE+LONGSIZE+L_cuserid+1] ; char * p_unique_id = isam_record ; char * p_area_class = p_unique_id + LONGSIZE ; char * p_area_name = p_area_class + LONGSIZE ; char * p_directory_name = p_area_name + ODB_MAX_AREA_NAME_LENGTH ; char * p_create_time = p_directory_name + ODB_MAX_DIRECTORY_NAME_LENGTH ; char * p_modify_time = p_create_time + LONGSIZE ; char * p_userid = p_modify_time + LONGSIZE ; if( ( fd = isbuild( database_filestub , sizeof( isam_record ) , & key0 , ISINOUT + ISEXCLLOCK ) ) < 0 ) { fprintf( stderr , "ODB Error for isbuild on file %s: retcode=%d\\nLine %d File '%s'\\n" , database_filestub , iserrno , __LINE__ , __FILE__ ) ; } if ( ( fptr = fopen( database_filestu2 , "w" ) ) == NULL ) { fprintf( stderr , "ODB Error for fopen on file %s:\\nLine %d File '%s'\\n" , database_filestu2 , __LINE__ , __FILE__ ) ; } else { fclose( fptr ) ; } thr_exit( 0 ) ; } int main( int argc , char ** argv ) { int ret , return_value = 0 ; thread_t create_dba_thread ; printf( "Main thread creating thread ...\\n" ); if ( thr_create ( NULL , NULL , create_dba , NULL , NULL , &create_dba_thread ) < 0 ) { char message[1024] ; sprintf( message , "Cannot start children_exists thread.\\n\\n%s" , strerror( errno ) ) ; printf( message ) ; } printf("Main thread joining with thread %d...\\n", create_dba_thread ); if ( ( ret = thr_join( create_dba_thread , NULL , &return_value) ) == -1) { char message[1024] ; sprintf( message , "Cannot join thread.\\n\\n%s" , strerror( errno ) ) ; printf( message ) ; } printf("Main sees return value %d from thread %d\\n", return_value, create_db a_thread ); } #####area.c#(end)################################################# ####Makefile###################################################### CC = /ap/CenterLine/bin/clcc # #__Solaris________________________________ CFLAGS = -I/opt/CISAM/include LFLAGS = -L/opt/CISAM/lib LIBS = -lisam -lthread area : area.o $(RM) $@ $(CC) $(LFLAGS) -o $@ area.o $(LIBS) area.o : ../ObjectsDatabaseP.h area.c $(CC) $(CFLAGS) -c -o $@ area.c ####Makefile#(end)################################################ Executing the application gives following result : ################################################################## btm05a\