|
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.
As an Amazon Associate we earn from qualifying purchases.
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.