]> granicus.if.org Git - postgresql/commitdiff
Exit cleanups I made yesterday caused pq_close() to be
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 23 Jul 1999 03:00:10 +0000 (03:00 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 23 Jul 1999 03:00:10 +0000 (03:00 +0000)
invoked during exit from a standalone backend, leading to core dump.
This is the cause of the recently reported initdb-time crash :-(.
Sorry folks...

src/backend/libpq/pqcomm.c

index e8361b85353482108ae0b2c93d4ccc7f2d736f10..5e129bc56ff13d5a0ba1790ca7e2d3639974cfa2 100644 (file)
@@ -28,7 +28,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- *     $Id: pqcomm.c,v 1.80 1999/07/17 20:17:03 momjian Exp $
+ *     $Id: pqcomm.c,v 1.81 1999/07/23 03:00:10 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -134,12 +134,16 @@ pq_getport(void)
 
 /* --------------------------------
  *             pq_close - shutdown libpq at backend exit
+ *
+ * Note: in a standalone backend MyProcPort will be null,
+ * don't crash during exit...
  * --------------------------------
  */
 void
 pq_close(void)
 {
-       close(MyProcPort->sock);
+       if (MyProcPort != NULL)
+               close(MyProcPort->sock);
 }