Ask a Question related to Informix, Design and Development.
-
Stefan Smeets #1
Problem opening/closing more Informix C-isam files
Hi,
I have the following problem in Informix C-Isam under Windows 2000, with
Microsoft Visual C/C++:
I open f.e. 5 isam files together.
Then I close these 5 files.
The program gives an exception after opening the 3th file.
It gives also an exception when I close the second file, if two files are
open.
Is there a problem with the c-isam library, or with the compilation option ?
I use Informix C-Isam v.7.25 (mentioned on CD-ROM).
Here the code of testing:
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <errno.h>
#include <isam.h>
main()
{
int i,j;
int fd[2048];
char fname[256];
int RecordSize=128;
struct keydesc sKey; // Pointer to key descriptor
sKey.k_flags = ISNODUPS;
sKey.k_nparts = 1;
sKey.k_part[0].kp_start = 0;
sKey.k_part[0].kp_leng = 10;
sKey.k_part[0].kp_type = CHARTYPE;
for (i=1;i<100i++) {
sprintf(fname,"c:\\temp\\file%04d",i);
if ((fd[i] = isbuild(fname,RecordSize,&sKey,ISINOUT+ISEXCLLOCK) ) < 0) {
fprintf(stderr, "Error opening is file %s - errno: %d iserrno:
%d\n",fname, errno, iserrno);
j=i-1;
i=2048;
}
}
for (i=1;i<j;i++) {
if (isclose(fd[i]) < 0) {
fprintf(stderr, "Error closing file %d\n",i);
}
}
printf("Program ended\n");
exit(0);
}
Thanks for the answers,
Stefan
Stefan Smeets Guest
-
Not Closing or opening Java or CSS...
http://www.zerofivezero.net/the_project102.html - Page in need of help I'm using a JavaScript image/text swap in the navigation and with the main... -
problem opening Corel Files
For a while I was able to open corel files as long as I had an equal or later version of illustrator but recently I have been having a problem... -
Which is better, opening and closing, or a massive file opening and a massive closing?
On Mon, 16 Feb 2004 11:16:54 -0600, wustl.edu (Shiping Wang) wrote: >Hi, >How can I rearrange an array in a specific order based on the order of... -
closing and opening MIAWS
im new to director and im having problems with this project im working on. i have a main stage, with 3 miaw's coming off it. all the controls to the... -
Opening or Closing a directory window on Mac?
We're trying to use Buddy API to either open or close a folder (actually, it's the root level directory window of the CD) on a Mac. It's easy to do... -
Jonathan Leffler #2
Re: Problem opening/closing more Informix C-isam files
Stefan Smeets wrote:
Should be int main(void) on most systems - MS Win2K might have other> Hi,
> I have the following problem in Informix C-Isam under Windows 2000, with
> Microsoft Visual C/C++:
> I open f.e. 5 isam files together.
> Then I close these 5 files.
> The program gives an exception after opening the 3th file.
> It gives also an exception when I close the second file, if two files are
> open.
> Is there a problem with the c-isam library, or with the compilation option ?
> I use Informix C-Isam v.7.25 (mentioned on CD-ROM).
> Here the code of testing:
>
> #include <stdio.h>
> #include <fcntl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <io.h>
> #include <errno.h>
> #include <isam.h>
>
> main()
views.
That's some pretty weird logic. You start as if you're going to run i> {
> int i,j;
> int fd[2048];
> char fname[256];
> int RecordSize=128;
> struct keydesc sKey; // Pointer to key descriptor
>
> sKey.k_flags = ISNODUPS;
> sKey.k_nparts = 1;
> sKey.k_part[0].kp_start = 0;
> sKey.k_part[0].kp_leng = 10;
> sKey.k_part[0].kp_type = CHARTYPE;
>
> for (i=1;i<100i++) {
> sprintf(fname,"c:\\temp\\file%04d",i);
> if ((fd[i] = isbuild(fname,RecordSize,&sKey,ISINOUT+ISEXCLLOCK) ) < 0) {
> fprintf(stderr, "Error opening is file %s - errno: %d iserrno:
> %d\n",fname, errno, iserrno);
> j=i-1;
> i=2048;
> }
> }
from 1 to 99, but then you play with i setting it 2048, so the loop
terminates after one cycle - creating one file. You've stashed the
ISAM file descriptor into fd[1], and set j to 0.
Here you run from 1 up to a value less than 0 (j), or do no iterations> for (i=1;i<j;i++) {
> if (isclose(fd[i]) < 0) {
> fprintf(stderr, "Error closing file %d\n",i);
> }
> }
of the loop. This is also excessively weird. It also bears no
resemblance to the circumstances you describe in your outline.
So, you'd probably best send the code that really does crash - this
might or might not crash, but it doesn't open 5 files. Or have you
solved the problem already?
I doubt if you'll be able to open 2048 C-ISAM files - I don't think
C-ISAM has that many slots in its internal table of C-ISAM file
descriptors.
On most systems, you'd do as well with return(0) instead of exit(0).> printf("Program ended\n");
> exit(0);
> }
You should include <stdlib.h> to get the declaration of exit().
--
Jonathan Leffler #include <disclaimer.h>
Email: [email]jleffler@earthlink.net[/email], [email]jleffler@us.ibm.com[/email]
Guardian of DBD::Informix v2003.04 -- [url]http://dbi.perl.org/[/url]
Jonathan Leffler Guest
-
Scott Burns #3
Re: Problem opening/closing more Informix C-isam files
Jonathan Leffler wrote:
<SNIP>> Stefan Smeets wrote:
Follow the brackets. Let's reformat:>>>>
>> for (i=1;i<100i++) {
>> sprintf(fname,"c:\\temp\\file%04d",i);
>> if ((fd[i] = isbuild(fname,RecordSize,&sKey,ISINOUT+ISEXCLLOCK) ) <
>> 0) {
>> fprintf(stderr, "Error opening is file %s - errno: %d iserrno:
>> %d\n",fname, errno, iserrno);
>> j=i-1;
>> i=2048;
>> }
>> }
>
> That's some pretty weird logic. You start as if you're going to run i
> from 1 to 99, but then you play with i setting it 2048, so the loop
> terminates after one cycle - creating one file. You've stashed the
> ISAM file descriptor into fd[1], and set j to 0.
for (i=1;i<100i++) /* ; missing? */
{
sprintf(fname,"c:\\temp\\file%04d",i);
if ((fd[i] = isbuild(fname,RecordSize,&sKey,ISINOUT+ISEXCLLOCK) ) < 0)
{
/* On error, print the error, set to i to 2048 to end the loop, then set
j to the actual number we _did_ open */
fprintf(stderr, "Error opening is file %s - errno: %d iserrno:
%d\n",fname, errno, iserrno);
j=i-1;
i=2048;
}
}
<SNIP>>>>> for (i=1;i<j;i++) {
>> if (isclose(fd[i]) < 0) {
>> fprintf(stderr, "Error closing file %d\n",i);
>> }
>> }
>
> Here you run from 1 up to a value less than 0 (j), or do no iterations
> of the loop.
for i = 1, i less than the number we succeeded in opening, add one each
itteration...
I think you read that last post just a little quickly...
--
Scott Burns
Mirrabooka Systems
Tel +61 7 3857 7899
Fax +61 7 3857 1368
Scott Burns Guest
-
Jonathan Leffler #4
Re: Problem opening/closing more Informix C-isam files
Scott Burns wrote:
> Jonathan Leffler wrote:
>>[...major snippage...]>> Stefan Smeets wrote:
> for i = 1, i less than the number we succeeded in opening, add one each
> itteration...
>
> I think you read that last post just a little quickly...
OK - the layout was less than stellar; I probably did misread it. I
withdraw all comments.
I'm not going to spend more time on it, I'm afraid. I spend a lot of
time looking at unreadable code, and I don't like it (doubly not when
it's my own code that I now deem unreadable - fortunately, that's not
my main concern at the moment, but it does happen).
--
Jonathan Leffler #include <disclaimer.h>
Email: [email]jleffler@earthlink.net[/email], [email]jleffler@us.ibm.com[/email]
Guardian of DBD::Informix v2003.04 -- [url]http://dbi.perl.org/[/url]
Jonathan Leffler Guest



Reply With Quote

