Menu

#73 strerror doesn't cache catalog lookups

1.0
open
nobody
CRTL (3)
2013-10-29
2013-10-29
No

David Jones of OSU fame wrote to me with the following problem:

"For the simple web scripts I was testing I noticed dozens of attempts to open SYS$NLSPATH:DECC$ERROR.CAT (which with the search list logicals involved is 4 different directories). The culprit is the strerror() function. To support internationalization, it looks for a message catalog in which to look up the error number on each invocation, opening and closing it if found."

Note that the catalog file doesn't normally exist, even after installing the VMSI18N kit, but the CRTL strerror still walks the search list pointed to by SYS$NLSPATH looking for it on each call to strerror. David found this by doing SET WATCH FILE and observing what happens.

There are two attachments, both provided by David. There is a simple Perl script using the CGI.pm module that reproduces the problem. There is also an optimized implementation of strerror that caches the results of messages it looks up.

It may be that Perl can avoid calling strerror as much as it does; I'll look into that. But it may also be that the CRTL can do a more efficient job with something like David's approach to caching results.

2 Attachments

Discussion


Log in to post a comment.