Skip to content

Commit f316222

Browse files
committed
Fix erroneous Assert() in syslogger process start in EXEC_BACKEND case,
per ITAGAKI Takahiro. Also, rewrite syslogger_forkexec() in hopes of eliminating the confusion in the first place.
1 parent bbda96d commit f316222

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/backend/postmaster/syslogger.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.39 2007/09/20 18:19:08 adunstan Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.40 2007/09/22 18:19:18 tgl Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -608,10 +608,8 @@ static pid_t
608608
syslogger_forkexec(void)
609609
{
610610
char *av[10];
611-
int ac = 0,
612-
bufc = 0,
613-
i;
614-
char numbuf[2][32];
611+
int ac = 0;
612+
char filenobuf[32];
615613

616614
av[ac++] = "postgres";
617615
av[ac++] = "--forklog";
@@ -620,21 +618,18 @@ syslogger_forkexec(void)
620618
/* static variables (those not passed by write_backend_variables) */
621619
#ifndef WIN32
622620
if (syslogFile != NULL)
623-
snprintf(numbuf[bufc++], 32, "%d", fileno(syslogFile));
621+
snprintf(filenobuf, sizeof(filenobuf), "%d",
622+
fileno(syslogFile));
624623
else
625-
strcpy(numbuf[bufc++], "-1");
624+
strcpy(filenobuf, "-1");
626625
#else /* WIN32 */
627626
if (syslogFile != NULL)
628-
snprintf(numbuf[bufc++], 32, "%ld",
627+
snprintf(filenobuf, sizeof(filenobuf), "%ld",
629628
_get_osfhandle(_fileno(syslogFile)));
630629
else
631-
strcpy(numbuf[bufc++], "0");
630+
strcpy(filenobuf, "0");
632631
#endif /* WIN32 */
633-
634-
/* Add to the arg list */
635-
Assert(bufc <= lengthof(numbuf));
636-
for (i = 0; i < bufc; i++)
637-
av[ac++] = numbuf[i];
632+
av[ac++] = filenobuf;
638633

639634
av[ac] = NULL;
640635
Assert(ac < lengthof(av));
@@ -652,7 +647,7 @@ syslogger_parseArgs(int argc, char *argv[])
652647
{
653648
int fd;
654649

655-
Assert(argc == 5);
650+
Assert(argc == 4);
656651
argv += 3;
657652

658653
#ifndef WIN32

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy