× 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.



 Thanks Scott 

I didn´t comment that after checking if the "opposite" flag is not there and 
writing the corresponding flag, y check again the opposite flag, to see if the 
situation that you have described occured, then one of the two will delete his 
flag and leave until the next iteration. Is possible that the situation that 
you described would happens along the day a few times, but like this we are 
sure that the folders are lock. 
On the other hand the suggestion about just one file would not work in my case, 
because we have 2 folders, with 2  RPG Programs, and more than one PC 
applications reading/writing.
Can you give me some examples about sharing/locking functionality with PC 
applications? Ideal would be that everytime the RPG program runs, will block 
the folder and the PC cannot write in IFS, and has to wait until the lock is 
there.
I have found the problem with the error. I did an opendir and readdir for 
checking XML files but didn´t do a closedir, so now is working OK.

Jaime

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im 
Auftrag von Scott Klement
Gesendet: Donnerstag, 27. Mai 2004 22:21
An: RPG programming on the AS400 / iSeries
Betreff: Re: error CPFA0A4.Too many open files for process.


Hello Jaime,

> I have to create a system that reads/writes files in IFS. At the same 
> time, an external application would have also to read/write files. To 
> avoid that both the AS400 and the PC application write/read at the 
> same time, we have tought we will write some kind of flag files, so 
> when the AS400 program works, will write a dummy AS400.txt file in the 
> folder (so the PC Application should not work until the AS400.txt is 
> gone). We launch our Program in the As400 (a lock that every 10 
> seconds will check the PC flag file, and if not found, then write the 
> AS400 flag file, checking again PC flag, just if the PC was writing 
> after writing the AS400, then working with the files that are in the 
> folder, and deleting the AS400 flag file).

Why not use the file sharing/locking functionality of the operating system?  
Deny access to the file until one program is done with it?

There's a chance for a timing error with the method that you're using.
What happens if the PC program and the AS/400 program both check for flag files 
at the exact same instant?  Neither one will be there -- so they'll both create 
flag files, again at the same instant, and both flag files will be there at the 
same time.  Then they'll both be working with the file at the same time.  
Obviously, the timing would have to be exact for this to happen, but it's 
certainly possible.  And, with it running over and over again all day long, the 
chances are pretty good that it will eventually hit that spot just perfectly.

Another possible solution, instead of using the locking functions of the OS, is 
to have the AS/400 complete it's job, THEN create a "I'm done" flag file.  As 
long as you only create this file after you've closed the file in the AS/400 
process, this would be safe -- since the flag file isn't
created until everything is ready.   The PC would then check for the flag
file BEFORE trying to read the actual data... and would only touch the data 
file if the flag file exists.  When it's completely done with the data file, it 
would delete the flag file.  the AS/400 would look for that file having been 
deleted, and use that as a signal that it's safe to build a new data file...


> For checking the PC flag file we use "access", for writing the AS400 
> flag file use "cpy" (a small CL program that does it), and for 
> deleting we use "unlink". The problem is: after some iteractions of 
> our AS400 lock, we get the error that the CL program cannot write the 
> AS400 flag file with error CPFA0A4.Too many open files for process. We 
> always unlink the file before the iteraction is finished. I have had a 
> look in the database about this error but didn´t found anything that 
> could help me. Any suggestions? Is any other way of getting this under 
> control?

the error means that there are too many files OPEN.   Not that too many
exist, unlinking the file won't help!  You have to close the open files.
My guess is that you're forgetting to close the data file when you're done 
writing it.

Granted, the "too many open files" error may be occurring when you execute the 
CPY command, but that doesn't mean the CPY command is the problem.
Your process can only have a certain number of open files -- let's say that 
number is 200 -- As soon as you try to open the 200th file, you'll
get an error.   So, if you still have 200 open instances of the data file
-- even if you're done with them and no longer using them -- the 201st might 
very well occur when you run CPY.  If that happens, you'll get the error.



_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To 
post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or 
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at 
http://archive.midrange.com/rpg400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.