Too many raster files open - Fixed!

George Chou gchou at gpz.com
Thu Jun 18 19:48:30 EDT 1998


Thanks to Bill Baker, Michael Hanratty and others for bringing up the issue
to the attention of the GRASS community and providing hints to solve the
problem.  The  solution is to replace the line

#define MAXFILES    30

in src/libes/gis/G.h with

#define MAXFILES    32000

The problem is that MAXFILES was used to compare with fd (file descriptor)
which is NOT a counter of open files in a process.  fd is assigned by the
system and it can be greater than MAXFILES even if the actual number of
open files is less than MAXFILES.  Since UNIX has a system level variable
OPEN_MAX (default = 64 for Solaris, 256 for some LINUX) it is safe to let
the system control the number of open files.  By assigning a large number
to MAXFILES, we simply make the following statement in opencell.c &
closecell.c always FALSE.

            if (fd >= MAXFILES)
                ......

Therefore, no other parts of code need to be modified.  A safe fix to the
problem.

For questions or comments on this fix please contact:

support at gpz.com

To get the GPZ source patch file for GRASS 4.2.1 version 16, go to GPZ's
home

http://www.gpz.com   

and click on a hyperlink near the top of the page.  The patch file is being
sent to Markus Neteler.

George Chou
GPZ Technology
gchou at gpz.com
****************************************************************************


GRASS-XMI - A Simple, Low-cost, Efficient and User-friendly tool for 
GRASS.  Version 1.3 is coming on June 25, 1998 -- http://www.gpz.com
****************************************************************************




       

----------
> From: Michael Hanratty <hanra001 at gold.tc.umn.edu>
> To: grassu at cecer.army.mil
> Subject: Re: Too many raster files open
> Date: Wednesday, June 18, 1997 2:11 PM
> 
> I have figured out the problem:
> 
> In message <9706130905.ZM27213 at impact1.hpcc.nectec.or.th>  writes:
> > Bill and Michael,
> > 
> > On Jun 12,  2:50pm, William L. Baker wrote:
> > > No one had a remedy, but someone did point out where the
> > > message comes from, but now when I look I see that I've lost that
> > > information.
> > 
> > I have a copy of the reply to Bill's posting from Dec 19, 1996 I
include the
> > entire message below.
> <snip> >
> > > 	There are two aspects to this problem (I think). The first is
> > > 	the origin of the warning. This warning is produced in
> > > 	file src/libes/gis/opencell.c if you try to open more than
> > > 	MAXFILES files. MAXFILES is a constant that is #defined to be
> > > 	30 in src/libes/gis/G.h
> > >
> > > 	I don't know why it's 30, probably the programmers thought that
> > > 	nobody in their right mind would need more than 30 open files
> > > 	anyawy (sounds vaguely familiar...).
> > > 	So I guess you could change this constant and recompile GRASS
> > > 	(you'd probably need to recompile or at least relink just about
> > > 	all of GRASS since this is a fairly central point).
> > >
> The problem is that the MAXFILES is compared to the file pointer, fd,
which is 
> never decremented.  Each new file opened is added as the next higher
file.  So, 
> it doesn't matter how often you close files, if you open more than
MAXFILES 
> during a program run, then the program will abort.  The best fix would be
to 
> have a static variable that is shared by the opencell and closecell
programs 
> that is incremented and decremented when a file is opened and closed, 
> respectively.  Then MAXFILES would be compared to the actual number of
files 
> open, instead of the number of files that have been opened since the
program was
> started.
> 
> Has anyone done this fix?
> 
> 
> Michael Hanratty                           Phone: (612) 627-4590
> St. Anthony Falls Laboratory               Fax: (612) 627-4609
> Dept. of Civil Engineering
> University of Minnesota
> Mississippi River @ 3rd Ave. SE
> Minneapolis, MN 55414
> 



More information about the grass-user mailing list