From: system@SendSpamHere.ORG
Sent: Friday, December 03, 1999 5:27 PM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: Need Help: DECC rms "acc" callback info self destructs on
later unrelated open()

In article <s4gen4upgsp184@corp.supernews.com>, "John E. Malmberg" <wb8tyw@qsl.net> writes:
>OpenVMS ALPHA 7.2
>DEC C 6.0
>
>I am using RMS "acc" callbacks with DEC C to capture the struct FAB pointer
>for later use.
>
>It works fine with a small test program, but when I use them in a larger
>program, (SMBD from SAMBA 2.0.6), the contents of a previously found fab
>structure get replaced in the middle of an decc$open() call.
>
>Am I making the wrong assumption that the FAB and RAB structures created on
>the original open() call should be left alone until a close happens?
>
>Or are the FAB and RAB structures that pointers are returned to only
>temporary copies, and can not be relied upon to exist after the callback
>exits.
>
>The DECC documentation I have does not say anything about the expected
>lifetime of these items, so I do not know if I have encountered a bug or a
>feature.
>
>Below is the sample code that works every time I run it.  It does the open()
>calls in the same way and order as what fails in the SMBD program.
>
>
>/* File: test.c  rms callback test
>**
>** 03-Dec-1999  J. Malmberg
>**
>****************************************************************************
>/
>/* test whether fcntl locking works on this system */
>
>#include <unistd.h>
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <sys/types.h>
>#include <fcntl.h>
>#include <rms.h>
>
>
>#define DATA "conftest.fcntl"
>
> /* Get the rms information */
>/*-------------------------*/
>void fport___rms_acc_callback
>       (unsigned long *firstarg,
>        struct FAB *__fab,
>        struct RAB *__rab)
>{
>        firstarg[0] = (unsigned long)__fab;
>        firstarg[1] = (unsigned long)__rab;
>}
>
>int main(int argc, char *argv[])
>{
>int fd0;
>int fd1;
>int fd2;
>unsigned long rmsptrs[2];
>struct FAB * fab1;
>struct RAB * rab1;
>int ret_stat;
>
>
>    ret_stat = fclose(stdin);
>
>    fd1 = open
>                (DATA,
>                 O_RDWR|O_CREAT|O_TRUNC,
>                 0600,
>                 "acc",
>                 (*fport___rms_acc_callback),
>                 rmsptrs,
>                 "shr=upd,del,put,get");
>
>    fab1 = (struct FAB *)rmsptrs[0];
>    rab1 = (struct RAB *)rmsptrs[0];


                                  ^--- Shouldn't this be rmsptrs[1]?

Perhaps, you've carried this problem throughout your other non-working
program.


>
>    printf("fab1->fab$l_dev = %d\n", fab1->fab$l_dev);
>
>    fd2 = open("SYS$SCRATCH:",O_RDONLY, 0, "dna=NON-EXISTANT.FILE");
>
>     /* In the test code this always has good data */
>     /* In the SMBD code, this always fails */
>    printf("fab1->fab$l_dev = %d\n", fab1->fab$l_dev);
>
>    close(fd1);
>
>    exit(1);
>}
>
>
>
>
--
VAXman- OpenVMS APE certification number: AAA-0001           VAXman@TMESIS.COM
