×
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.
Steve Seroogy wrote:
Scott,
If I understand what you are saying instead of opening up each
directory I can use one opendir() statement that opens up
/transfer/WMS/Upload/MAPICS/.
Correct so far.
Then if I had only one opendir() statement the is run every 4 minutes
it could run up to 13 hours before have to end and resubmit the job?
No. Wrong. If you close every directory that you open, then your
program will run forever without resubmitting.
Your problem now is that you're opening 4 directories and closing 1.
That means that you've left 3 of them open. Doing this you'll
eventually run out of file handles.
Close them all every time and you won't have a problem.
Here's an analogy... imagine a small family, four people. Mother,
father, son, daughter. Every day they eat dinner together. The
household has 200 dinner plates. Each person in the family is
responsible for washing his/her plate after dinner. But the son is
"too busy", so he doesn't wash his plate. It's not a problem at
first... day 1 there are 200 plates available. Day 2 there are 199,
etc... they eat well for awhile, but eventually they run out of dinner
plates because the son never washes his.
When they run out, the son says "why don't we buy more plates? We keep
running out!" But, the ever-wise father says "idiot boy, we'd never run
out of plates if you washed yours every night. We don't need more
plates, we need you to do your job and wash your plate!"
And that's exactly what's happening with your opendir() calls -- well,
okay, not EXACTLY... but the point is, every time you call opendir(),
you dirty a plate. Every time you call closedir() you wash it, and it
can be re-used.
The problem with the code you posted: You call opendir() four times,
and you call closedir() once. That means that your program will work
for awhile, but eventually you'll run out of file handles. If you close
them all every time, you won't.
As an Amazon Associate we earn from qualifying purchases.