Re: C-ISAM Locking
Posted in 1998
Topics: General Discussion
Thanks for your reply, I have tried as you suggested, it again, works ok if I link with C-ISAM 3.10.03B, but simply refuses to find any locks if I link with C-ISAM 5.05.UC2. Here is the source for the program used to lock a record..... ----snip----- #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <isam.h> void main(void) { int ret,fd,datfd; struct dictinfo info; char *rec; fd=isopen("ffterm",ISMANULOCK+ISINOUT); if(fd<0) { printf("Error opening file: %d\\n",iserrno); exit(1); } isindexinfo(fd,&info,0); printf("record size=%d, records=%d\\n",info.di_recsize,info.di_nrecords); rec = (char *)malloc(info.di_recsize+5); isread(fd,rec,ISFIRST+ISLOCK); printf("Locked record : %.20s - press return to unlock\\n",rec,iserrno); getchar(); free(rec); isclose(fd); close(datfd); } ----- snip ------ And here is the code I am using to check for a lock on the .dat file ... ----- snip ------ #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <isam.h> int lock(int fd,unsigned long loc,unsigned long len); void main(void) { int ret,fd,datfd; struct dictinfo info; fd=isopen("ffterm",ISMANULOCK+ISINOUT); if(fd<0) { printf("Error opening file: %d\\n",iserrno); exit(1); } if((datfd=open("ffterm.dat",O_RDWR))<0) { printf("Error opening file: %d\\n",errno); exit(2); } isindexinfo(fd,&info,0); printf("record size=%d, records=%d\\n",info.di_recsize,info.di_nrecords); if(lock(datfd,0,0x7FFFFFFFL)) { printf("There is a lock somewhere....\\n"); } else printf("There are no locks on that file\\n"); isclose(fd); close(datfd); } int lock(int fd,unsigned long loc,unsigned long len) { int retc; struct flock arg; arg.l_whence = SEEK_SET; arg.l_start = loc; arg.l_len = len; arg.l_type = F_WRLCK; retc=fcntl(fd,F_GETLK,&arg); if(arg.l_type==F_UNLCK) return(0); else return(1); } If I link the programs with C-ISAM version 3.10.03B, this is the output ..... ---snip--- record size=2500, records=40 There is a lock somewhere.... ---snip--- If I link the programs with C-ISAM version 5.05.UC2, this is the output..... ---snip--- record size=2500, records=40 There are no locks on that file ---snip--- even though there are locks on that file. Please can you offer any more help ? I am desparate to get this working :-( Thanks again, Robin Grayson