Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: reproduced elusive cygwin bug


  • From: Jason Tishler <jason(at)tishler(dot)net>
  • To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • Cc: Michael Adler <adler(at)glimpser(dot)org>, Tom Pfau <T(dot)Pfau(at)emCrit(dot)com>, Pgsql-Cygwin <pgsql-cygwin(at)postgresql(dot)org>
  • Subject: Re: reproduced elusive cygwin bug
  • Date: Wed, 16 Jan 2002 12:04:56 -0500
  • Message-id: <20020116170456.GE1804@dothill.com> <text/plain>

Tom,

On Wed, Jan 16, 2002 at 11:02:06AM -0500, Tom Lane wrote:
> I said:
> > Hmm.  But pg_internal.init is not held open, or shouldn't be.  It should
> > be read once and immediately closed during backend startup.
> 
> Well damn.  init_irels() forgets to close the file.  Will fix for 7.2.

The attached patch (against Cygwin PostgreSQL 7.1.3-1) solves this
problem.  I will release 7.1.3-2 ASAP.

Jason
--- relcache.c.orig	Wed Jan 16 11:12:49 2002
+++ relcache.c	Wed Jan 16 11:44:36 2002
@@ -2664,6 +2664,7 @@ init_irels(void)
 		/* first read the relation descriptor length */
 		if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2674,6 +2675,7 @@ init_irels(void)
 		/* then, read the Relation structure */
 		if ((nread = FileRead(fd, (char *) ird, len)) != len)
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2686,6 +2688,7 @@ init_irels(void)
 		/* next, read the access method tuple form */
 		if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2693,6 +2696,7 @@ init_irels(void)
 		am = (Form_pg_am) palloc(len);
 		if ((nread = FileRead(fd, (char *) am, len)) != len)
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2702,6 +2706,7 @@ init_irels(void)
 		/* next read the relation tuple form */
 		if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2709,6 +2714,7 @@ init_irels(void)
 		relform = (Form_pg_class) palloc(len);
 		if ((nread = FileRead(fd, (char *) relform, len)) != len)
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2724,6 +2730,7 @@ init_irels(void)
 		{
 			if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
 			{
+				FileClose(fd);
 				write_irels();
 				return;
 			}
@@ -2732,6 +2739,7 @@ init_irels(void)
 
 			if ((nread = FileRead(fd, (char *) ird->rd_att->attrs[i], len)) != len)
 			{
+				FileClose(fd);
 				write_irels();
 				return;
 			}
@@ -2740,6 +2748,7 @@ init_irels(void)
 		/* next, read the index strategy map */
 		if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2747,6 +2756,7 @@ init_irels(void)
 		strat = (IndexStrategy) palloc(len);
 		if ((nread = FileRead(fd, (char *) strat, len)) != len)
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2772,6 +2782,7 @@ init_irels(void)
 		/* finally, read the vector of support procedures */
 		if ((nread = FileRead(fd, (char *) &len, sizeof(len))) != sizeof(len))
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2779,6 +2790,7 @@ init_irels(void)
 		support = (RegProcedure *) palloc(len);
 		if ((nread = FileRead(fd, (char *) support, len)) != len)
 		{
+			FileClose(fd);
 			write_irels();
 			return;
 		}
@@ -2789,6 +2801,7 @@ init_irels(void)
 		RelationCacheInsert(ird);
 	}
 	criticalRelcachesBuilt = true;
+	FileClose(fd);
 }
 
 static void


Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group