Operating System - OpenVMS
1748063 Members
5827 Online
108758 Solutions
New Discussion

Re: sys$synch iosb returning status as SS$_ENDOFFILE

 
allin-in-one
Frequent Advisor

sys$synch iosb returning status as SS$_ENDOFFILE

we have an application which is reading from the socket writing to disk using sys$qio. Using sys$synch to check the completion of operation.In sys$synch iosb returning status as SS$_ENDOFFILE. Please advise under what conditions this can occur.

9 REPLIES 9
Duncan Morris
Honored Contributor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

Welcome to the forum!

 

Some more information would be useful:

 

VAX/Alpha/Itanium, OS versions?

 

Example of your code?

 

If you are truly using $QIOW then $SYNCH is superfluous.

 

" The synchronous services such as $QIOW execute code that checks for the true completion status in the same way that $SYNCH does"

 

 

Duncan

allin-in-one
Frequent Advisor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

Thanks you. Sorry, it is a typo the service I am using is sys$qio  NOT sysqiow. the system is  IA64 OpenVMS V8.3.

Duncan Morris
Honored Contributor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

.. and your code sample, so that we can see exactly what your QIO command looks like, and the corresponding SYNCH operation?

 

 

allin-in-one
Frequent Advisor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

The code for sys$qio and sys$synch are as below .

 

stat = sys$qio(0, chan, IO$_WRITEVBLK | IO$M_NOVCACHE,  iosb,0, 0,    buf,  len,  blkn, 0, 0, 0);

 

int   stat = sys$synch(EFN$C_EFN, (short unsigned int *)iosb);

Duncan Morris
Honored Contributor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

From the $SYNCH service description:

 

"The Synchronize service checks the completion status of a system service that completes asynchronously. The service whose completion status is to be checked must have been called with the efn and iosb arguments specified, because the $SYNCH service uses the event flag and I/O status block of the service to be checked."

 

see: http://h71000.www7.hp.com/doc/84final/4527/4527pro_116.html#jun_584

 

Your code for the $QIO did not specify an efn, and you then used a completely different efn for the $SYNCH call!

 

You must specificy a non-zero efn in the $QIO call, and then use the same efn and the same iosb for the $SYNCH call.

 

Duncan 

allin-in-one
Frequent Advisor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

Thank for the reply.

 

actually the code is

int

stat = sys$synch(EFN$C_EFN, (int*)iosb);

 if (stat == SS$_ILLEFC)

sys$synch(0, (int*)iosb);

 

As per the document http://h71000.www7.hp.com/doc/82final/5841/5841pro_020.html we can specify efn as EFN$C_ENF for ZERO  event flag EFN$C_EFN (128) is not supported (in VAX  and early ALPHA). Please correct me.

 

Actually this code is working in almost all scenarios. But I have seen a problem recently in which iosb is returning SS$_ENDOFFILE in some cases. I would like to know under what circumstances iosb status will be SS$_ENDOFFILE. From the manuals I couldn't find the circumstances for this scenario.

 

Once again thanks for your help.

Hein van den Heuvel
Honored Contributor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

Like any good engineer, I like to see code and learn about versions and so one, but folks this is an EASY self-inflicted error.

 

QIO  IO$_WRITEVBLK returning   ENDOFFILE means... drum roll.... the END OF FILE was reached. No kiddding.

 

It appears the folks writing the application were just smart enough to be dangerous as suggested by the QIO + SYNC usage and the little known IO$M_NOVCACHE modifier.

But if you use QIO to write to a file, then the program needs to pre-allocate or extent the file as needed.

 

Sample below.

Good luck,

Hein

 

$create QIO_EOF.c
#include        <rms>           /* defines for rabs and fabs    */
#include        <stdio>         /* defins printf...             */
#include        <string>
#include        <iodef>
main(int argc,char *argv[])
{
char            buf[64*512];
struct FAB      outfab, *fab;   /* Allocate fabs and a pointer to fab */
int             s, i=0, len=512, blkn=1, sys$create(), sys$qiow();
unsigned short  iosb[4];

outfab = cc$rms_fab;                    /* Make this a real FAB (bid and bln) */
outfab.fab$b_fac = FAB$M_PUT;           /* record write access                */
outfab.fab$l_fop = FAB$M_UFO;
outfab.fab$l_fna = (argc > 1) ? argv[1] : "TMP.TMP";
outfab.fab$b_fns = strlen(outfab.fab$l_fna);
outfab.fab$l_alq = 10;


s = sys$create ( &outfab );     /* Try to open target file          */
if (s & 1) {
   s = sys$qiow(0, outfab.fab$l_stv, IO$_WRITEVBLK | IO$M_NOVCACHE,  iosb,0, 0,    buf,  len,  blkn, 0, 0, 0);
   printf ("qio %d. vbn = %d, status = 0x%0X, iosb = 0x%0X\n", ++i, blkn, s, iosb[0]);
   blkn = 10000;
   s = sys$qiow(0, outfab.fab$l_stv, IO$_WRITEVBLK | IO$M_NOVCACHE,  iosb,0, 0,    buf,  len,  blkn, 0, 0, 0);
   printf ("qio %d. vbn = %d, status = 0x%0X, iosb = 0x%0X\n", ++i, blkn, s, iosb[0]);
   if (s&1) s =  iosb[0];
   return s;
   }
}

$ cc QIO_EOF
$ link QIO_EOF
$ run QIO_EOF
qio 1. vbn = 1, status = 0x1, iosb = 0x1
qio 2. vbn = 10000, status = 0x1, iosb = 0x870
%SYSTEM-W-ENDOFFILE, end of file

 

 

 

Hein van den Heuvel
Honored Contributor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

$ help /messa/fac=SYS ENDOFFILE

 ENDOFFILE,  end of file

  Facility:     SYSTEM, System Services

  Explanation:  This message was received because of one or more of the
                following conditions:

 
                o The file system ACP encountered the end of the allocated
                  space for a virtual I/O operation or an attempted
                  truncation.


  User Action:  If necessary, modify the source program to detect and respond to the condition.

 

allin-in-one
Frequent Advisor

Re: sys$synch iosb returning status as SS$_ENDOFFILE

Once  again thanks for the help .