Problem opening/closing more Informix C-isam files

Ask a Question related to Informix, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: Problem opening/closing more Informix C-isam files

    Stefan Smeets wrote:
    > 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()
    Should be int main(void) on most systems - MS Win2K might have other
    views.
    > {
    > 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;
    > }
    > }
    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<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. 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.

    > printf("Program ended\n");
    > exit(0);
    > }
    On most systems, you'd do as well with return(0) instead of 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

  4. #3

    Default Re: Problem opening/closing more Informix C-isam files

    Jonathan Leffler wrote:
    > Stefan Smeets wrote:
    <SNIP>
    >
    >>
    >> 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.
    Follow the brackets. Let's reformat:
    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;
    }
    }
    >
    >> 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.
    <SNIP>

    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

  5. #4

    Default Re: Problem opening/closing more Informix C-isam files

    Scott Burns wrote:
    > Jonathan Leffler wrote:
    >
    >> Stefan Smeets wrote:
    >[...major snippage...]
    > 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139