× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Than you Scott. I will have to fudge and probably write the api calls
in RPG since we are V5R3. I should have put that in the original post.




Chris Bipes
Director of Information Services
CrossCheck, Inc.


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Wednesday, August 20, 2008 10:25 AM
To: Midrange Systems Technical Discussion
Subject: Re: ifs locks

Hi Chris,

Does anyone have a sample code in CL for checking and waiting for a
lock to clear for a file / directory in the IFS?

I assume you mean a stream file, right? I don't know of any way to wait
on a directory, since folks don't generally hold a lock on a directory.
So you'd have to wait until every object in the directory is unused.

Hmmm.. I've never attempted to do this in CL, only in RPG. But, as long
as you're able to use ILE CL in V5R4 or later, it should be possible in
CL.

Here's how I'd code it (this is off the top of my head, but should be
very close to being correct):

PGM
DCL VAR(&FILE) TYPE(*CHAR) LEN(500)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(x'00')
DCL VAR(&FD) TYPE(*INT) LEN(4) VALUE(-1)
DCL VAR(&RC) TYPE(*INT) LEN(4) VALUE(-1)
DCL VAR(&FLAGS) TYPE(*INT) LEN(4) VALUE(0)
DCL VAR(&ERRPTR) TYPE(*PTR)
DCL VAR(&ERRNO) TYPE(*INT) LEN(4) +
STG(*BASED) BASPTR(&ERRPTR)
DCL VAR(&ERRDEC) TYPE(*DEC) LEN(4 0)
DCL VAR(&ERRCHR) TYPE(*CHAR) LEN(4)
DCL VAR(&ERRID) TYPE(*CHAR) LEN(7)
DCL VAR(&O_RDONLY) TYPE(*INT) LEN(4) VALUE(1)
DCL VAR(&O_NOSHARE) TYPE(*INT) LEN(4) VALUE(524288)

/* &O_RDONLY = Open the IFS file for reading only. +
&O_NOSHARE = Do not share the IFS file with anyone +
(the manual calls this O_SHARE_NONE) */

CHGVAR VAR(&FLAGS) VALUE(&O_RDONLY + &O_NOSHARE)
CHGVAR VAR(&FILE) VALUE('/tmp/test.txt' *CAT &NULL)

DOUNTIL (&ERRID *NE 'CPE3029')

CHGVAR VAR(&ERRID) VALUE(' ')

CALLPRC PRC('open') PARM((&FILE *BYREF) +
(&FLAGS *BYVAL)) +
RTNVAL(&FD)
IF (&FD *NE -1) DO
CHGVAR VAR(&ERRID) VALUE(' ')
CALLPRC PRC('close') PARM((&FD *BYVAL)) +
RTNVAL(&RC)
ENDDO
ELSE DO
CALLPRC PRC('__errno') RTNVAL(&ERRPTR)
CHGVAR VAR(&ERRDEC) VALUE(&ERRNO)
CHGVAR VAR(&ERRCHR) VALUE(&ERRDEC)
CHGVAR VAR(&ERRID) VALUE('CPE' *CAT &ERRCHR)
IF (&ERRID *EQ 'CPE3029') THEN(DLYJOB DLY(1))
ENDDO

ENDDO

IF (&ERRID *NE ' ') DO
SNDPGMMSG MSGID(&ERRID) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
RETURN
ENDDO

ENDPGM


Once again, I want to stress that this is ILE (not OPM) CL. And it
requires V5R4 or later to work properly. To compile it, you need to do
the following:

CRTCLMOD WAITIFS SRCFILE(xxx/xxx)
CRTPGM WAITIFS BNDDIR(QC2LE)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.