]> granicus.if.org Git - postgresql/commitdiff
Fix erroneous Assert() in syslogger process start in EXEC_BACKEND case,
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 22 Sep 2007 18:19:18 +0000 (18:19 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 22 Sep 2007 18:19:18 +0000 (18:19 +0000)
per ITAGAKI Takahiro.  Also, rewrite syslogger_forkexec() in hopes of
eliminating the confusion in the first place.

src/backend/postmaster/syslogger.c

index 001e206a96c76fceebf5ca49178b780c8079fe34..8ac38f0baa57149096d8c21ad0276671cdc49e33 100644 (file)
@@ -18,7 +18,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.39 2007/09/20 18:19:08 adunstan Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.40 2007/09/22 18:19:18 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -608,10 +608,8 @@ static pid_t
 syslogger_forkexec(void)
 {
        char       *av[10];
-       int                     ac = 0,
-                               bufc = 0,
-                               i;
-       char            numbuf[2][32];
+       int                     ac = 0;
+       char            filenobuf[32];
 
        av[ac++] = "postgres";
        av[ac++] = "--forklog";
@@ -620,21 +618,18 @@ syslogger_forkexec(void)
        /* static variables (those not passed by write_backend_variables) */
 #ifndef WIN32
        if (syslogFile != NULL)
-               snprintf(numbuf[bufc++], 32, "%d", fileno(syslogFile));
+               snprintf(filenobuf, sizeof(filenobuf), "%d",
+                                fileno(syslogFile));
        else
-               strcpy(numbuf[bufc++], "-1");
+               strcpy(filenobuf, "-1");
 #else                                                  /* WIN32 */
        if (syslogFile != NULL)
-               snprintf(numbuf[bufc++], 32, "%ld",
+               snprintf(filenobuf, sizeof(filenobuf), "%ld",
                                 _get_osfhandle(_fileno(syslogFile)));
        else
-               strcpy(numbuf[bufc++], "0");
+               strcpy(filenobuf, "0");
 #endif   /* WIN32 */
-
-       /* Add to the arg list */
-       Assert(bufc <= lengthof(numbuf));
-       for (i = 0; i < bufc; i++)
-               av[ac++] = numbuf[i];
+       av[ac++] = filenobuf;
 
        av[ac] = NULL;
        Assert(ac < lengthof(av));
@@ -652,7 +647,7 @@ syslogger_parseArgs(int argc, char *argv[])
 {
        int                     fd;
 
-       Assert(argc == 5);
+       Assert(argc == 4);
        argv += 3;
 
 #ifndef WIN32