Bug 83 - zonec does not close zone files
zonec does not close zone files
Status: RESOLVED FIXED
Product: NSD
Classification: Unclassified
Component: Zonec Code
2.1.x
i386 FreeBSD
: P2 normal
Assigned To: NSD team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-06-22 04:51 CEST by Kazunori Fujiwara
Modified: 2004-06-23 10:04 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazunori Fujiwara 2004-06-22 04:51:41 CEST
zonec zone_read() function does not fclose() zonefile.
  zone_open() opens zonefile and stores FILE* pointer to 'yyin'.
  and then yyparse() parses zonefile.
  But this file pointer is not closed.

So it causes "Too many open files" error.
I found this bug when I tested 100000 zones in one nameserver.

I made this quick patch and tested 500000 zones in one nsd.zones file.
nsd-2.1.0 has very good performance compared with BIND 8.3/9.3 in this test.

--- zonec.c-	Thu Apr 22 22:39:47 2004
+++ zonec.c	Mon Jun 21 18:10:39 2004
@@ -1251,6 +1251,9 @@
 	memset(nsecbits, 0, 8192);
 	yyparse();
 
+	fclose(yyin);
+	yyin = NULL;
+
 	fflush(stdout);
 	totalerrors += current_parser->errors;
 }
Comment 1 Miek Gieben 2004-06-22 14:34:04 CEST
Patch looks ok. I will do some test this afternoon or tomorrow. 
2.1.1 will have this applied
Comment 2 Miek Gieben 2004-06-23 10:04:08 CEST
applied